Skip to content
Merged
Changes from 1 commit
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
Next Next commit
fix(encryption): Ignore shared files in encrypt-all command
Copying and renaming a share will not encrypt it anyway. It will get
 encrypted when the owner’s files get encrypted.

Signed-off-by: Côme Chilliet <[email protected]>
  • Loading branch information
come-nc committed Aug 7, 2025
commit c022a1a1b1bb5a1993064c073f342c3eacb93c03
21 changes: 9 additions & 12 deletions apps/encryption/lib/Crypto/EncryptAll.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
use OCA\Encryption\KeyManager;
use OCA\Encryption\Users\Setup;
use OCA\Encryption\Util;
use OCP\Files\FileInfo;
use OCP\IConfig;
use OCP\IL10N;
use OCP\IUser;
Expand Down Expand Up @@ -247,14 +248,18 @@ protected function encryptUsersFiles($uid, ProgressBar $progress, $userCount) {
$content = $this->rootView->getDirectoryContent($root);
foreach ($content as $file) {
$path = $root . '/' . $file['name'];
if ($this->rootView->is_dir($path)) {
if ($file->isShared()) {
$progress->setMessage("Skip shared file/folder $path");
$progress->advance();
continue;
} elseif ($file->getType() === FileInfo::TYPE_FOLDER) {
$directories[] = $path;
continue;
} else {
$progress->setMessage("encrypt files for user $userCount: $path");
$progress->advance();
try {
if ($this->encryptFile($path) === false) {
if ($this->encryptFile($file, $path) === false) {
$progress->setMessage("encrypt files for user $userCount: $path (already encrypted)");
$progress->advance();
}
Expand All @@ -275,17 +280,9 @@ protected function encryptUsersFiles($uid, ProgressBar $progress, $userCount) {
}
}

/**
* encrypt file
*
* @param string $path
* @return bool
*/
protected function encryptFile($path) {

protected function encryptFile(FileInfo $fileInfo, string $path): bool {
// skip already encrypted files
$fileInfo = $this->rootView->getFileInfo($path);
if ($fileInfo !== false && $fileInfo->isEncrypted()) {
if ($fileInfo->isEncrypted()) {
return true;
}

Expand Down