-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow configuring the location of the appdata_[instanceid]
folder
#36337
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -27,7 +27,11 @@ | |
namespace OC\Files\AppData; | ||
|
||
use OCP\Cache\CappedMemoryCache; | ||
use OC\Files\Filesystem; | ||
use OC\Files\SimpleFS\SimpleFolder; | ||
use OC\Files\Node\LazyRoot; | ||
use OC\Files\Storage\LocalRootStorage; | ||
use OC\Files\Mount\MountPoint; | ||
use OC\SystemConfig; | ||
use OCP\Files\Folder; | ||
use OCP\Files\IAppData; | ||
|
@@ -55,10 +59,28 @@ class AppData implements IAppData { | |
public function __construct(IRootFolder $rootFolder, | ||
SystemConfig $systemConfig, | ||
string $appId) { | ||
$this->rootFolder = $rootFolder; | ||
$this->config = $systemConfig; | ||
$this->appId = $appId; | ||
$this->folders = new CappedMemoryCache(); | ||
|
||
$this->rootFolder = new LazyRoot(function () use ($rootFolder, $systemConfig) { | ||
if ($appdatadirectory = $systemConfig->getValue('appdatadirectory', null)) { | ||
$instanceId = $systemConfig->getValue('instanceid', null); | ||
if ($instanceId === null) { | ||
throw new \RuntimeException('no instance id!'); | ||
} | ||
|
||
$folderName = 'appdata_' . $instanceId; | ||
|
||
$arguments = [ | ||
'datadir' => $appdatadirectory, | ||
]; | ||
$storage = new LocalRootStorage($arguments); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This should just be |
||
$mount = new MountPoint($storage, $folderName, $arguments); | ||
Filesystem::getMountManager()->addMount($mount); | ||
} | ||
return $rootFolder; | ||
}); | ||
} | ||
|
||
private function getAppDataFolderName() { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,6 +25,8 @@ | |
*/ | ||
namespace OC\Files\Cache; | ||
|
||
use OC\Files\Filesystem; | ||
|
||
class LocalRootScanner extends Scanner { | ||
public function scanFile($file, $reuseExisting = 0, $parentId = -1, $cacheData = null, $lock = true, $data = null) { | ||
if ($this->shouldScanPath($file)) { | ||
|
@@ -43,7 +45,11 @@ public function scan($path, $recursive = self::SCAN_RECURSIVE, $reuse = -1, $loc | |
} | ||
|
||
private function shouldScanPath(string $path): bool { | ||
$storageId = $this->storage->getId(); | ||
$mount = Filesystem::getMountManager()->findByStorageId($storageId); | ||
$mountPoint = sizeof($mount) == 1 ? $mount[0]->getMountPoint() : "null"; | ||
|
||
$path = trim($path, '/'); | ||
return $path === '' || str_starts_with($path, 'appdata_') || str_starts_with($path, '__groupfolders'); | ||
return $path === '' || str_starts_with($path, 'appdata_') || str_starts_with($path, '__groupfolders') || str_starts_with($mountPoint, '/appdata_'); | ||
Comment on lines
+48
to
+53
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If you want to stop the scanner from touching the new appdata mountpoint, you can instead create a storage with a "noop" scanner. |
||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why are you creating a new
LazyRoot
?