Skip to content

Commit 687261f

Browse files
authored
Merge pull request #57921 from nextcloud/fix/snowflake_lock_dir
fix(snowflakes): create file lock files into lock directory
2 parents 2d0a24f + e15b429 commit 687261f

2 files changed

Lines changed: 4 additions & 2 deletions

File tree

lib/private/Snowflake/FileSequence.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,9 @@ public function __construct(
3333

3434
private function ensureWorkdirExists(): void {
3535
if (is_dir($this->workDir)) {
36+
if (!is_writable($this->workDir)) {
37+
throw new \Exception('File sequence directory exists but is not writable');
38+
}
3639
return;
3740
}
3841

@@ -104,6 +107,6 @@ public function nextId(int $serverId, int $seconds, int $milliseconds): int {
104107
}
105108

106109
private function getFilePath(int $fileId): string {
107-
return $this->workDir . sprintf(self::LOCK_FILE_FORMAT, $fileId);
110+
return $this->workDir . '/' . sprintf(self::LOCK_FILE_FORMAT, $fileId);
108111
}
109112
}

tests/lib/Snowflake/FileSequenceTest.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,5 @@ public function tearDown():void {
3030
foreach (glob($lockDirectory . '/*') as $file) {
3131
unlink($file);
3232
}
33-
rmdir($lockDirectory);
3433
}
3534
}

0 commit comments

Comments
 (0)