Skip to content

Commit 2f8e225

Browse files
committed
remove copy of property that meant downloader would only lock one source at a time
1 parent 5f3f999 commit 2f8e225

File tree

2 files changed

+11
-6
lines changed

2 files changed

+11
-6
lines changed

src/SPC/store/Downloader.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -650,6 +650,12 @@ private static function isAlreadyDownloaded(string $name, bool $force, int $down
650650
return true;
651651
}
652652
}
653+
if (!$force && $download_as === SPC_DOWNLOAD_PACKAGE && $lock_item !== null) {
654+
if (file_exists($path = LockFile::getLockFullPath($lock_item))) {
655+
logger()->notice("Source [{$name}] already downloaded: {$path}");
656+
return true;
657+
}
658+
}
653659
return false;
654660
}
655661
}

src/SPC/store/LockFile.php

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -69,17 +69,16 @@ public static function put(string $lock_name, ?array $lock_content): void
6969
{
7070
self::init();
7171

72-
$data = self::$lock_file_content;
73-
if ($lock_content === null && isset($data[$lock_name])) {
74-
self::removeLockFileIfExists($data[$lock_name]);
75-
unset($data[$lock_name]);
72+
if ($lock_content === null && isset(self::$lock_file_content[$lock_name])) {
73+
self::removeLockFileIfExists(self::$lock_file_content[$lock_name]);
74+
unset(self::$lock_file_content[$lock_name]);
7675
} else {
77-
$data[$lock_name] = $lock_content;
76+
self::$lock_file_content[$lock_name] = $lock_content;
7877
}
7978

8079
// Write the updated lock data back to the file
8180
FileSystem::createDir(dirname(self::LOCK_FILE));
82-
file_put_contents(self::LOCK_FILE, json_encode($data, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES));
81+
file_put_contents(self::LOCK_FILE, json_encode(self::$lock_file_content, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES));
8382
}
8483

8584
/**

0 commit comments

Comments
 (0)