Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions apps/files_versions/lib/Storage.php
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,10 @@ public static function store($filename) {
return false;
}

if (self::ignoredByHiddenFile($file)) {
return false;
}

$mount = $file->getMountPoint();
if ($mount instanceof SharedMount) {
$ownerFolder = $rootFolder->getUserFolder($mount->getShare()->getShareOwner());
Expand Down Expand Up @@ -1007,4 +1011,34 @@ protected static function getExpiration() {
}
return self::$application->getContainer()->get(Expiration::class);
}

/**
* returns TRUE if a file named '.noversion' is found
* in the current folder or in a parent folder
*/
private static function ignoredByHiddenFile(Node $node): bool {
if (!$node instanceof Folder) {
try {
$node = $node->getParent();
} catch (NotFoundException $e) {
\OCP\Server::get(LoggerInterface::class)->warning('parent folder must exist', ['exception' => $e]);
return false;
}
}

$i = 0;
while ($i++ < 30) {
if ($node->nodeExists('.noversion')) {
return true;
}

try {
$node = $node->getParent();
} catch (NotFoundException) {
break;
}
}

return false;
}
}
Loading