I guess I found two bugs in the staticSync. Maybe they are features, but I just didn't realize ;)
We are using static-sync with settings:
- $syncdir = "/mnt/batch-import";
- $nogo = ""
- $staticsync_whitelist_folders = array(
'/campaign/',
'/event/'
); - $staticsync_ingest = true;
- $staticsync_ingest_force = true;
1. Bug-fix: Files in syncdir-root are being imported.
When configuring and testing, I noticed that files in /mnt/batch-import/*.jpg were also processed and imported. However the white-listening should only include files in the folders /mnt/batch-import/campaign/ and /mnt/batch-import/event/.
File: /pages/tools/staticsync.php
Added IF construct in line 287. Marked in red:
if(
($filetype == 'dir' || $filetype == 'link')
&& strpos($nogo, $file) === false
&& strpos($file, $staticsync_alternatives_suffix) === false
)
{
// Recurse
ProcessFolder("{$fullpath}");
}
# -------FILES---------------
if( //This if is new
($filetype == 'file')
&& count($staticsync_whitelist_folders) > 0
&& dirname($shortpath) == "."
)
{
// Files in staticsync-dir will be skipped, if whitelisted folders are configured
continue;
} // Changes end here.
if (($filetype == "file") && (substr($file,0,1) != ".") && (strtolower($file) != "thumbs.db"))
{
if (isset($staticsync_file_minimum_age) && (time() - filectime($folder . "/" . $file) < $staticsync_file_minimum_age))
{
// Don't process this file yet as it is too new
echo " - " . $file . " is too new (" . (time() - filectime($folder . "/" . $file)) . " seconds), skipping\n";
continue;
}
2. Bug-fix: Recursive scan does not work
I've also noted that only /mnt/batch-import/campaign/ and /mnt/batch-import/event/ will be scanned for files. Folders below "campaign" and "event" did not been entered.
This is how I fixed it.
File: /include/file_functions.php @ line 75
/**
* Checks if a path is part of a whitelisted list of paths. This applies to both folders and files.
*
* Note: the function is not supposed to check/ validate the syntax of the path (ie. UNIX/ Windows)
*
* @param string $path Path which is going to be checked against whitelisted paths
* @param array $whitelisted_paths List of whitelisted paths
*
* @return boolean
*/
function isPathWhitelisted($path, array $whitelisted_paths)
{
foreach($whitelisted_paths as $whitelisted_path)
{
//if(substr_compare($whitelisted_path, $path, 0, strlen($path)) === 0) //original
if(strpos('/'.$path.'/', $whitelisted_path) !== false) // New IF
{
return true;
}
}
return false;
}
Not sure if these changes are going to cause any other issues. So far it looked all right and is working on my system.
Hope I can help. I will update, if changes are needed.