// Old Todo:
// - Crypt/decrypt button in the userinterface
// - Setting if crypto should be on by default
-// - Add a setting "Don´t encrypt files larger than xx because of performance
+// - Add a setting "Don´t encrypt files larger than xx because of performance
// reasons"
namespace OCA\Encryption;
//// DONE: new data filled files added via webdav get encrypted
//// DONE: new data filled files added via webdav are readable via webdav
- //// DONE: reading unencrypted files when encryption is enabled works via
+ //// DONE: reading unencrypted files when encryption is enabled works via
//// webdav
//// DONE: files created & encrypted via web ui are readable via webdav
\OCP\Util::writeLog('Encryption library', \OC_DB::getErrorMessage($query), \OCP\Util::ERROR);
return false;
}
-
+
$result = $query->execute($args);
if (\OCP\DB::isError($result)) {
\OCP\Util::writeLog('Encryption library', \OC_DB::getErrorMessage($result), \OCP\Util::ERROR);
return false;
}
-
+
return is_numeric($result);
-
+
}
/**
$filePath = $directory . '/' . $this->view->getRelativePath('/' . $file);
$relPath = \OCA\Encryption\Helper::stripUserFilesPath($filePath);
- // If the path is a directory, search
+ // If the path is a directory, search
// its contents
if ($this->view->is_dir($filePath)) {
$isEncryptedPath = $this->isEncryptedPath($filePath);
// If the file is encrypted
- // NOTE: If the userId is
- // empty or not set, file will
+ // NOTE: If the userId is
+ // empty or not set, file will
// detected as plain
// NOTE: This is inefficient;
// scanning every file like this
//relative to data/<user>/file
$relPath = $plainFile['path'];
+ //get file info
+ $fileInfo = \OC\Files\Filesystem::getFileInfo($plainFile['path']);
+
//relative to /data
$rawPath = '/' . $this->userId . '/files/' . $plainFile['path'];
// Add the file to the cache
\OC\Files\Filesystem::putFileInfo($relPath, array(
- 'encrypted' => true,
- 'size' => $size,
- 'unencrypted_size' => $size
- ));
+ 'encrypted' => true,
+ 'size' => $size,
+ 'unencrypted_size' => $size,
+ 'etag' => $fileInfo['etag']
+ ));
}
// Encrypt legacy encrypted files
&& !Keymanager::getShareKey($this->view, $this->userId, $filePath) // NOTE: we can't use isShared() here because it's a post share hook so it always returns true
) {
- // The file has no shareKey, and its keyfile must be
+ // The file has no shareKey, and its keyfile must be
// decrypted conventionally
$plainKeyfile = Crypt::keyDecrypt($encKeyfile, $privateKey);
}
- // If recovery is enabled, add the
+ // If recovery is enabled, add the
// Admin UID to list of users to share to
if ($recoveryEnabled) {
// Find recoveryAdmin user ID