Skip to content

Commit

Permalink
Bugfix: when a target storage drive file copy is on the same drive as…
Browse files Browse the repository at this point in the history
… the source file (most probably the LZ), skip this file when creating file copies in parallel; it will be copied afterwards using a rename

Ref #225
  • Loading branch information
gboudreau committed Apr 5, 2020
1 parent 3fcee18 commit 5119f39
Showing 1 changed file with 20 additions and 5 deletions.
25 changes: 20 additions & 5 deletions includes/StorageFile.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,13 @@ public static function create_file_copies_from_metafiles($metafiles, $share, $fu
foreach ($file_copies_to_create as $key => $metafile) {
if ($create_copies_in_parallel) {
/** @noinspection PhpUndefinedVariableInspection */
$it_worked = $copy_results[$key];
$it_worked = (bool) @$copy_results[$key];
} else {
$it_worked = FALSE;
}

// Create a file copy, if parallel copying failed (for this file copy), or is disabled
if (!$it_worked) {
$it_worked = static::create_file_copy($source_file, $metafile->path);
}

Expand Down Expand Up @@ -153,10 +158,20 @@ public static function create_file_copies($source_file, &$metafiles) {
$file_copies_to_create = [];
foreach ($metafiles as $key => $metafile) {
$destination_file = $metafile->path;
if (gh_is_file($source_file) && $source_file == $destination_file) {
Log::debug(" Destination $destination_file is the same as the source. Nothing to do here; this file copy is ready!");
$copy_results[$key] = TRUE;
continue;
if (gh_is_file($source_file)) {
if ($source_file == $destination_file) {
Log::debug(" Destination $destination_file is the same as the source. Nothing to do here; this file copy is ready!");
$copy_results[$key] = TRUE;
continue;
}

$source_dev = gh_file_deviceid($source_file);
$target_dev = gh_file_deviceid(dirname($destination_file));
if ($source_dev === $target_dev && $source_dev !== FALSE && !Config::get(CONFIG_ALLOW_MULTIPLE_SP_PER_DRIVE)) {
Log::debug(" Destination $destination_file is on the same drive as the source. Will be moved into storage pool drive later.");
$copy_results[$key] = FALSE;
continue;
}
}

$temp_path = static::get_temp_filename($destination_file);
Expand Down

0 comments on commit 5119f39

Please sign in to comment.