X Tutup
Skip to content

Commit 66ed39d

Browse files
authored
Merge pull request #39683 from owncloud/enterprise-4946
Fix files:checksums:verify for a single file
2 parents dceb296 + 42e1ba4 commit 66ed39d

File tree

3 files changed

+33
-2
lines changed

3 files changed

+33
-2
lines changed

apps/files/lib/Command/VerifyChecksums.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ public function execute(InputInterface $input, OutputInterface $output) {
115115
$this->exitStatus = self::EXIT_INVALID_ARGS;
116116
return $this->exitStatus;
117117
}
118-
if ($node === FileInfo::TYPE_FILE) {
118+
if ($node->getType() === FileInfo::TYPE_FILE) {
119119
$this->verifyChecksumsForFile($node, $input, $output);
120120
} else {
121121
$this->verifyChecksumsForFolder($node, $input, $output);

apps/files/tests/Command/VerifyChecksumsTest.php

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ private function createFileForUser($uid, $path, $content) {
117117
* @return bool|IUser
118118
*/
119119
private function createRandomUser($number) {
120-
$userName = $this->getUniqueID("$number-verifycheksums");
120+
$userName = $this->getUniqueID("$number-verifychecksums");
121121
$user = $this->createUser($userName);
122122
$this->loginAsUser($userName);
123123

@@ -271,6 +271,32 @@ public function testOnlyFilesInGivenPathArgumentAreRepaired() {
271271
$this->assertEquals(self::BROKEN_CHECKSUM_STRING, $file4->getChecksum());
272272
}
273273

274+
/**
275+
* @depends testBrokenFilesAreRepairedWithRepairArgument
276+
*/
277+
public function testSingleFileInGivenPathArgumentIsRepaired() {
278+
279+
/** @var File $file1 */
280+
$file1 = $this->testFiles[0]['file'];
281+
/** @var File $file2 */
282+
$file2 = $this->testFiles[1]['file'];
283+
284+
$this->breakChecksum($file1);
285+
$this->breakChecksum($file2);
286+
287+
$this->cmd->execute([
288+
'-r' => null,
289+
'-u' => $this->user1,
290+
'-p' => "dir/nested/somefile.txt"
291+
]);
292+
293+
$this->assertChecksumsAreCorrect([
294+
$this->testFiles[0],
295+
]);
296+
297+
$this->assertEquals(self::BROKEN_CHECKSUM_STRING, $file2->getChecksum());
298+
}
299+
274300
public function testOnlyFilesOfAGivenUserAreRepaired() {
275301

276302
/** @var File $file1 */

changelog/unreleased/39683

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
Bugfix: Fix files:checksums:verify for a single file
2+
3+
Fixed an issue where running files:checksums:verify for a single file would fail.
4+
5+
https://github.com/owncloud/core/pull/39683

0 commit comments

Comments
 (0)
X Tutup