Skip to content

Commit f299305

Browse files
committed
chore: WIP - debug for CI
Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
1 parent 14b8770 commit f299305

File tree

3 files changed

+29
-1
lines changed

3 files changed

+29
-1
lines changed

apps/files_versions/tests/VersioningTest.php

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -427,7 +427,20 @@ public function testMoveFileIntoSharedFolderAsRecipient(): void {
427427
// move file into the shared folder as recipient
428428
$success = Filesystem::rename('/test.txt', '/folder1/test.txt');
429429

430-
$this->assertTrue($success);
430+
// TODO: Voir is $v2 existe pour voir si c’est la copie ou la suppression qui foire
431+
// Mettre du debug dans Wrapper/Encrytion::copyBetweenStorage c’est le suspect n-1
432+
$versionsFolder1 = '/' . self::TEST_VERSIONS_USER . '/files_versions';
433+
434+
$v1Renamed = $versionsFolder1 . '/folder1/test.txt.v' . $t1;
435+
$v2Renamed = $versionsFolder1 . '/folder1/test.txt.v' . $t2;
436+
var_dump([
437+
'success' => $success,
438+
'v1 exists' => $this->rootView->file_exists($v1),
439+
'v2 exists' => $this->rootView->file_exists($v2),
440+
'v1Renamed exists' => $this->rootView->file_exists($v1Renamed),
441+
'v2Renamed exists' => $this->rootView->file_exists($v2Renamed),
442+
]);
443+
$this->assertTrue($success); // renvoi true :-O
431444
$this->assertFalse($this->rootView->file_exists($v1));
432445
$this->assertFalse($this->rootView->file_exists($v2));
433446

lib/private/Files/ObjectStore/ObjectStoreStorage.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,13 +176,17 @@ private function rmObjects(ICacheEntry $entry): bool {
176176
}
177177

178178
public function unlink(string $path): bool {
179+
echo "[DEBUG] unlink($path) " . __FILE__ . ':' . __LINE__ . "\n";
179180
$path = $this->normalizePath($path);
181+
echo "[DEBUG] unlink($path) " . __FILE__ . ':' . __LINE__ . "\n";
180182
$entry = $this->getCache()->get($path);
181183

182184
if ($entry instanceof ICacheEntry) {
183185
if ($entry->getMimeType() === ICacheEntry::DIRECTORY_MIMETYPE) {
186+
echo "[DEBUG] unlink directory $path " . __FILE__ . ':' . __LINE__ . "\n";
184187
return $this->rmObjects($entry);
185188
} else {
189+
echo "[DEBUG] unlink file $path " . __FILE__ . ':' . __LINE__ . "\n";
186190
return $this->rmObject($entry);
187191
}
188192
}

lib/private/Files/Storage/Wrapper/Encryption.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,8 +169,11 @@ public function file_put_contents(string $path, mixed $data): int|float|false {
169169
}
170170

171171
public function unlink(string $path): bool {
172+
echo "[DEBUG] unlink($path) " . __FILE__ . ':' . __LINE__ . "\n";
172173
$fullPath = $this->getFullPath($path);
174+
echo "[DEBUG] unlink($fullPath) " . __FILE__ . ':' . __LINE__ . "\n";
173175
if ($this->util->isExcluded($fullPath)) {
176+
echo "[DEBUG] excluded $fullPath " . __FILE__ . ':' . __LINE__ . "\n";
174177
return $this->storage->unlink($path);
175178
}
176179

@@ -522,20 +525,25 @@ public function moveFromStorage(
522525
// - remove $this->copyBetweenStorage
523526

524527
if (!$sourceStorage->isDeletable($sourceInternalPath)) {
528+
echo "[DEBUG] $sourceInternalPath $targetInternalPath not deletable " . __FILE__ . ':' . __LINE__ . "\n";
525529
return false;
526530
}
527531

528532
$result = $this->copyBetweenStorage($sourceStorage, $sourceInternalPath, $targetInternalPath, $preserveMtime, true);
533+
echo "[DEBUG] $sourceInternalPath $targetInternalPath copy:$result " . __FILE__ . ':' . __LINE__ . "\n";
529534
if ($result) {
535+
echo "[DEBUG] $sourceInternalPath $targetInternalPath copy success " . __FILE__ . ':' . __LINE__ . "\n";
530536
if ($sourceStorage->instanceOfStorage(ObjectStoreStorage::class)) {
531537
/** @var ObjectStoreStorage $sourceStorage */
532538
$sourceStorage->setPreserveCacheOnDelete(true);
533539
}
534540
try {
535541
if ($sourceStorage->is_dir($sourceInternalPath)) {
536542
$result = $sourceStorage->rmdir($sourceInternalPath);
543+
echo "[DEBUG] $sourceInternalPath rmdir:$result " . __FILE__ . ':' . __LINE__ . "\n";
537544
} else {
538545
$result = $sourceStorage->unlink($sourceInternalPath);
546+
echo "[DEBUG] $sourceInternalPath unlink:$result " . __FILE__ . ':' . __LINE__ . "\n";
539547
}
540548
} finally {
541549
if ($sourceStorage->instanceOfStorage(ObjectStoreStorage::class)) {
@@ -621,10 +629,12 @@ private function copyBetweenStorage(
621629
bool $preserveMtime,
622630
bool $isRename,
623631
): bool {
632+
echo "[DEBUG] $sourceInternalPath $targetInternalPath $isRename " . __FILE__ . ':' . __LINE__ . "\n";
624633
// for versions we have nothing to do, because versions should always use the
625634
// key from the original file. Just create a 1:1 copy and done
626635
if ($this->isVersion($targetInternalPath) ||
627636
$this->isVersion($sourceInternalPath)) {
637+
echo "[DEBUG] $sourceInternalPath $targetInternalPath $isRename " . __FILE__ . ':' . __LINE__ . "\n";
628638
// remember that we try to create a version so that we can detect it during
629639
// fopen($sourceInternalPath) and by-pass the encryption in order to
630640
// create a 1:1 copy of the file
@@ -642,6 +652,7 @@ private function copyBetweenStorage(
642652
}
643653
$this->updateEncryptedVersion($sourceStorage, $sourceInternalPath, $targetInternalPath, $isRename, true);
644654
}
655+
echo "[DEBUG] $result " . __FILE__ . ':' . __LINE__ . "\n";
645656
return $result;
646657
}
647658

0 commit comments

Comments
 (0)