Fixed bug #2146 - Import script does not accept relative paths
This commit is contained in:
parent
e2eb5003fd
commit
510d3a618a
|
@ -43,8 +43,10 @@ fi
|
||||||
filelistpathname=.
|
filelistpathname=.
|
||||||
|
|
||||||
#-------------------------------------------------------------------------------
|
#-------------------------------------------------------------------------------
|
||||||
# Do recursive import
|
# Do import
|
||||||
#-------------------------------------------------------------------------------
|
#-------------------------------------------------------------------------------
|
||||||
|
invokePwd=$PWD
|
||||||
|
echo $invokePwd
|
||||||
cd $phpdir
|
cd $phpdir
|
||||||
|
|
||||||
php -q campcaster-import.php "$@" || exit 1
|
php -q campcaster-import.php --dir "$invokePwd" "$@" || exit 1
|
||||||
|
|
|
@ -80,6 +80,7 @@ function import_err($p_pearErrorObj, $txt='')
|
||||||
*
|
*
|
||||||
* @param string $p_filepath
|
* @param string $p_filepath
|
||||||
* You can pass in a directory or file name.
|
* You can pass in a directory or file name.
|
||||||
|
* This must be the full absolute path to the file, not relative.
|
||||||
* @param string $p_importMode
|
* @param string $p_importMode
|
||||||
* @param boolean $p_testOnly
|
* @param boolean $p_testOnly
|
||||||
*
|
*
|
||||||
|
@ -100,7 +101,6 @@ function camp_import_audio_file($p_filepath, $p_importMode = null, $p_testOnly =
|
||||||
|
|
||||||
$fileCount = 0;
|
$fileCount = 0;
|
||||||
$duplicates = 0;
|
$duplicates = 0;
|
||||||
$p_filepath = realpath(rtrim($p_filepath));
|
|
||||||
|
|
||||||
if (!file_exists($p_filepath)) {
|
if (!file_exists($p_filepath)) {
|
||||||
echo " * WARNING: File does not exist: $p_filepath\n";
|
echo " * WARNING: File does not exist: $p_filepath\n";
|
||||||
|
@ -197,6 +197,7 @@ echo "Campcaster Import Script\n";
|
||||||
echo "========================\n";
|
echo "========================\n";
|
||||||
$g_errors = 0;
|
$g_errors = 0;
|
||||||
|
|
||||||
|
//print_r($argv);
|
||||||
$start = intval(date('U'));
|
$start = intval(date('U'));
|
||||||
|
|
||||||
PEAR::setErrorHandling(PEAR_ERROR_RETURN);
|
PEAR::setErrorHandling(PEAR_ERROR_RETURN);
|
||||||
|
@ -207,7 +208,8 @@ if (PEAR::isError($CC_DBC)) {
|
||||||
}
|
}
|
||||||
$CC_DBC->setFetchMode(DB_FETCHMODE_ASSOC);
|
$CC_DBC->setFetchMode(DB_FETCHMODE_ASSOC);
|
||||||
|
|
||||||
$parsedCommandLine = Console_Getopt::getopt($argv, "thcl", array("test", "help", "copy", "link"));
|
$parsedCommandLine = Console_Getopt::getopt($argv, "thcld", array("test", "help", "copy", "link", "dir="));
|
||||||
|
//print_r($parsedCommandLine);
|
||||||
if (PEAR::isError($parsedCommandLine)) {
|
if (PEAR::isError($parsedCommandLine)) {
|
||||||
printUsage();
|
printUsage();
|
||||||
exit(1);
|
exit(1);
|
||||||
|
@ -222,6 +224,7 @@ $files = $parsedCommandLine[1];
|
||||||
|
|
||||||
$testonly = FALSE;
|
$testonly = FALSE;
|
||||||
$importMode = null;
|
$importMode = null;
|
||||||
|
$currentDir = null;
|
||||||
foreach ($cmdLineOptions as $tmpValue) {
|
foreach ($cmdLineOptions as $tmpValue) {
|
||||||
$optionName = $tmpValue[0];
|
$optionName = $tmpValue[0];
|
||||||
$optionValue = $tmpValue[1];
|
$optionValue = $tmpValue[1];
|
||||||
|
@ -233,11 +236,14 @@ foreach ($cmdLineOptions as $tmpValue) {
|
||||||
case "c":
|
case "c":
|
||||||
case "--copy":
|
case "--copy":
|
||||||
$importMode = "copy";
|
$importMode = "copy";
|
||||||
break 2;
|
break;
|
||||||
case 'l':
|
case 'l':
|
||||||
case '--link':
|
case '--link':
|
||||||
$importMode = "link";
|
$importMode = "link";
|
||||||
break 2;
|
break;
|
||||||
|
case '--dir':
|
||||||
|
$currentDir = $optionValue;
|
||||||
|
break;
|
||||||
case "t":
|
case "t":
|
||||||
case "--test":
|
case "--test":
|
||||||
$testonly = TRUE;
|
$testonly = TRUE;
|
||||||
|
@ -254,7 +260,11 @@ $filecount = 0;
|
||||||
$duplicates = 0;
|
$duplicates = 0;
|
||||||
if (is_array($files)) {
|
if (is_array($files)) {
|
||||||
foreach ($files as $filepath) {
|
foreach ($files as $filepath) {
|
||||||
list($tmpCount, $tmpDups) = camp_import_audio_file($filepath, $importMode, $testonly);
|
$fullPath = realpath($filepath);
|
||||||
|
if (!$fullPath && !is_null($currentDir)) {
|
||||||
|
$fullPath = "$currentDir/$filepath";
|
||||||
|
}
|
||||||
|
list($tmpCount, $tmpDups) = camp_import_audio_file($fullPath, $importMode, $testonly);
|
||||||
$filecount += $tmpCount;
|
$filecount += $tmpCount;
|
||||||
$duplicates += $tmpDups;
|
$duplicates += $tmpDups;
|
||||||
}
|
}
|
||||||
|
@ -271,7 +281,9 @@ echo "==========================================================================
|
||||||
echo " *** Import mode: $importMode\n";
|
echo " *** Import mode: $importMode\n";
|
||||||
echo " *** Files imported: $filecount\n";
|
echo " *** Files imported: $filecount\n";
|
||||||
echo " *** Duplicate files (not imported): $duplicates\n";
|
echo " *** Duplicate files (not imported): $duplicates\n";
|
||||||
echo " *** Errors: $g_errors\n";
|
if ($g_errors > 0) {
|
||||||
|
echo " *** Errors: $g_errors\n";
|
||||||
|
}
|
||||||
echo " *** Total: ".($filecount+$duplicates)." files in $time seconds = $speed files/second.\n";
|
echo " *** Total: ".($filecount+$duplicates)." files in $time seconds = $speed files/second.\n";
|
||||||
echo "==========================================================================\n";
|
echo "==========================================================================\n";
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue