summaryrefslogtreecommitdiffstats
path: root/apps/files_external/lib
diff options
context:
space:
mode:
Diffstat (limited to 'apps/files_external/lib')
-rw-r--r--apps/files_external/lib/config.php58
-rw-r--r--apps/files_external/lib/config/configadapter.php2
-rw-r--r--apps/files_external/lib/personalmount.php10
-rw-r--r--apps/files_external/lib/smb.php9
4 files changed, 19 insertions, 60 deletions
diff --git a/apps/files_external/lib/config.php b/apps/files_external/lib/config.php
index 7a869847a63..f29e08dad25 100644
--- a/apps/files_external/lib/config.php
+++ b/apps/files_external/lib/config.php
@@ -90,6 +90,7 @@ class OC_Mount_Config {
$userStoragesService->setUser($user);
foreach ($userGlobalStoragesService->getStorages() as $storage) {
+ /** @var \OCA\Files_external\Lib\StorageConfig $storage */
$mountPoint = '/'.$uid.'/files'.$storage->getMountPoint();
$mountEntry = self::prepareMountPointEntry($storage, false);
foreach ($mountEntry['options'] as &$option) {
@@ -267,26 +268,6 @@ class OC_Mount_Config {
}
/**
- * Write the mount points to the config file
- *
- * @param string|null $user If not null, personal for $user, otherwise system
- * @param array $data Mount points
- */
- public static function writeData($user, $data) {
- if (isset($user)) {
- $file = \OC::$server->getUserManager()->get($user)->getHome() . '/mount.json';
- } else {
- $config = \OC::$server->getConfig();
- $datadir = $config->getSystemValue('datadirectory', \OC::$SERVERROOT . '/data/');
- $file = $config->getSystemValue('mount_file', $datadir . '/mount.json');
- }
-
- $content = json_encode($data, JSON_PRETTY_PRINT);
- @file_put_contents($file, $content);
- @chmod($file, 0640);
- }
-
- /**
* Get backend dependency message
* TODO: move into AppFramework along with templates
*
@@ -397,39 +378,9 @@ class OC_Mount_Config {
}
/**
- * Merges mount points
- *
- * @param array $data Existing mount points
- * @param array $mountPoint New mount point
- * @param string $mountType
- * @return array
- */
- private static function mergeMountPoints($data, $mountPoint, $mountType) {
- $applicable = key($mountPoint);
- $mountPath = key($mountPoint[$applicable]);
- if (isset($data[$mountType])) {
- if (isset($data[$mountType][$applicable])) {
- // Merge priorities
- if (isset($data[$mountType][$applicable][$mountPath])
- && isset($data[$mountType][$applicable][$mountPath]['priority'])
- && !isset($mountPoint[$applicable][$mountPath]['priority'])
- ) {
- $mountPoint[$applicable][$mountPath]['priority']
- = $data[$mountType][$applicable][$mountPath]['priority'];
- }
- $data[$mountType][$applicable]
- = array_merge($data[$mountType][$applicable], $mountPoint[$applicable]);
- } else {
- $data[$mountType] = array_merge($data[$mountType], $mountPoint);
- }
- } else {
- $data[$mountType] = $mountPoint;
- }
- return $data;
- }
-
- /**
* Returns the encryption cipher
+ *
+ * @return AES
*/
private static function getCipher() {
$cipher = new AES(AES::MODE_CBC);
@@ -441,6 +392,9 @@ class OC_Mount_Config {
* Computes a hash based on the given configuration.
* This is mostly used to find out whether configurations
* are the same.
+ *
+ * @param array $config
+ * @return string
*/
public static function makeConfigHash($config) {
$data = json_encode(
diff --git a/apps/files_external/lib/config/configadapter.php b/apps/files_external/lib/config/configadapter.php
index 4e37e6a4004..4f68c3c7fde 100644
--- a/apps/files_external/lib/config/configadapter.php
+++ b/apps/files_external/lib/config/configadapter.php
@@ -114,7 +114,7 @@ class ConfigAdapter implements IMountProvider {
* @return \OCP\Files\Mount\IMountPoint[]
*/
public function getMountsForUser(IUser $user, IStorageFactory $loader) {
- $this->migrator->migrateUser();
+ $this->migrator->migrateUser($user);
$mounts = [];
diff --git a/apps/files_external/lib/personalmount.php b/apps/files_external/lib/personalmount.php
index 26f68ba32db..34ae516ea5e 100644
--- a/apps/files_external/lib/personalmount.php
+++ b/apps/files_external/lib/personalmount.php
@@ -35,12 +35,12 @@ class PersonalMount extends MountPoint implements MoveableMount {
protected $storagesService;
/** @var int */
- protected $storageId;
+ protected $numericStorageId;
/**
* @param UserStoragesService $storagesService
* @param int $storageId
- * @param string|\OC\Files\Storage\Storage $storage
+ * @param \OCP\Files\Storage $storage
* @param string $mountpoint
* @param array $arguments (optional) configuration for the storage backend
* @param \OCP\Files\Storage\IStorageFactory $loader
@@ -57,7 +57,7 @@ class PersonalMount extends MountPoint implements MoveableMount {
) {
parent::__construct($storage, $mountpoint, $arguments, $loader, $mountOptions);
$this->storagesService = $storagesService;
- $this->storageId = $storageId;
+ $this->numericStorageId = $storageId;
}
/**
@@ -67,7 +67,7 @@ class PersonalMount extends MountPoint implements MoveableMount {
* @return bool
*/
public function moveMount($target) {
- $storage = $this->storagesService->getStorage($this->storageId);
+ $storage = $this->storagesService->getStorage($this->numericStorageId);
// remove "/$user/files" prefix
$targetParts = explode('/', trim($target, '/'), 3);
$storage->setMountPoint($targetParts[2]);
@@ -82,7 +82,7 @@ class PersonalMount extends MountPoint implements MoveableMount {
* @return bool
*/
public function removeMount() {
- $this->storagesService->removeStorage($this->storageId);
+ $this->storagesService->removeStorage($this->numericStorageId);
return true;
}
}
diff --git a/apps/files_external/lib/smb.php b/apps/files_external/lib/smb.php
index a94840ead59..80b44a4cbdf 100644
--- a/apps/files_external/lib/smb.php
+++ b/apps/files_external/lib/smb.php
@@ -33,6 +33,7 @@ use Icewind\SMB\Exception\Exception;
use Icewind\SMB\Exception\NotFoundException;
use Icewind\SMB\NativeServer;
use Icewind\SMB\Server;
+use Icewind\Streams\CallbackWrapper;
use Icewind\Streams\IteratorDirectory;
use OC\Files\Filesystem;
@@ -189,7 +190,10 @@ class SMB extends Common {
return $this->share->read($fullPath);
case 'w':
case 'wb':
- return $this->share->write($fullPath);
+ $source = $this->share->write($fullPath);
+ return CallBackWrapper::wrap($source, null, null, function () use ($fullPath) {
+ unset($this->statCache[$fullPath]);
+ });
case 'a':
case 'ab':
case 'r+':
@@ -219,7 +223,8 @@ class SMB extends Common {
}
$source = fopen($tmpFile, $mode);
$share = $this->share;
- return CallBackWrapper::wrap($source, null, null, function () use ($tmpFile, $fullPath, $share) {
+ return CallbackWrapper::wrap($source, null, null, function () use ($tmpFile, $fullPath, $share) {
+ unset($this->statCache[$fullPath]);
$share->put($tmpFile, $fullPath);
unlink($tmpFile);
});