Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
die_coolen_jungs
our_own_cloud_project
Commits
75e8b398
Commit
75e8b398
authored
Dec 18, 2014
by
Morris Jobke
Browse files
Merge pull request #12879 from owncloud/mountconfig
Add mount specific options
parents
891474b0
2eab0f21
Changes
19
Hide whitespace changes
Inline
Side-by-side
apps/files/tests/ajax_rename.php
View file @
75e8b398
...
...
@@ -107,7 +107,7 @@ class Test_OC_Files_App_Rename extends \Test\TestCase {
'etag'
=>
'abcdef'
,
'directory'
=>
'/'
,
'name'
=>
'new_name'
,
))));
)
,
null
)));
$result
=
$this
->
files
->
rename
(
$dir
,
$oldname
,
$newname
);
...
...
apps/files/tests/helper.php
View file @
75e8b398
...
...
@@ -24,7 +24,8 @@ class Test_Files_Helper extends \Test\TestCase {
'mtime'
=>
$mtime
,
'type'
=>
$isDir
?
'dir'
:
'file'
,
'mimetype'
=>
$isDir
?
'httpd/unix-directory'
:
'application/octet-stream'
)
),
null
);
}
...
...
apps/files_external/lib/config/configadapter.php
View file @
75e8b398
...
...
@@ -33,10 +33,11 @@ class ConfigAdapter implements IMountProvider {
$objectClass
=
$options
[
'options'
][
'objectstore'
][
'class'
];
$options
[
'options'
][
'objectstore'
]
=
new
$objectClass
(
$options
[
'options'
][
'objectstore'
]);
}
$mountOptions
=
isset
(
$options
[
'mountOptions'
])
?
$options
[
'mountOptions'
]
:
[];
if
(
isset
(
$options
[
'personal'
])
&&
$options
[
'personal'
])
{
$mounts
[]
=
new
PersonalMount
(
$options
[
'class'
],
$mountPoint
,
$options
[
'options'
],
$loader
);
$mounts
[]
=
new
PersonalMount
(
$options
[
'class'
],
$mountPoint
,
$options
[
'options'
],
$loader
,
$mountOptions
);
}
else
{
$mounts
[]
=
new
MountPoint
(
$options
[
'class'
],
$mountPoint
,
$options
[
'options'
],
$loader
);
$mounts
[]
=
new
MountPoint
(
$options
[
'class'
],
$mountPoint
,
$options
[
'options'
],
$loader
,
$mountOptions
);
}
}
return
$mounts
;
...
...
apps/files_trashbin/lib/helper.php
View file @
75e8b398
...
...
@@ -31,8 +31,10 @@ class Helper
return
$result
;
}
list
(
$storage
,
$internalPath
)
=
$view
->
resolvePath
(
$dir
);
$mount
=
$view
->
getMount
(
$dir
);
$storage
=
$mount
->
getStorage
();
$absoluteDir
=
$view
->
getAbsolutePath
(
$dir
);
$internalPath
=
$mount
->
getInternalPath
(
$absoluteDir
);
if
(
is_resource
(
$dirContent
))
{
$originalLocations
=
\
OCA\Files_Trashbin\Trashbin
::
getLocations
(
$user
);
...
...
@@ -65,7 +67,7 @@ class Helper
if
(
$originalPath
)
{
$i
[
'extraData'
]
=
$originalPath
.
'/'
.
$id
;
}
$result
[]
=
new
FileInfo
(
$absoluteDir
.
'/'
.
$i
[
'name'
],
$storage
,
$internalPath
.
'/'
.
$i
[
'name'
],
$i
);
$result
[]
=
new
FileInfo
(
$absoluteDir
.
'/'
.
$i
[
'name'
],
$storage
,
$internalPath
.
'/'
.
$i
[
'name'
],
$i
,
$mount
);
}
}
closedir
(
$dirContent
);
...
...
lib/private/connector/sabre/directory.php
View file @
75e8b398
...
...
@@ -72,7 +72,7 @@ class OC_Connector_Sabre_Directory extends OC_Connector_Sabre_Node
$path
=
$this
->
fileView
->
getAbsolutePath
(
$this
->
path
)
.
'/'
.
$name
;
// using a dummy FileInfo is acceptable here since it will be refreshed after the put is complete
$info
=
new
\
OC\Files\FileInfo
(
$path
,
null
,
null
,
array
());
$info
=
new
\
OC\Files\FileInfo
(
$path
,
null
,
null
,
array
()
,
null
);
$node
=
new
OC_Connector_Sabre_File
(
$this
->
fileView
,
$info
);
return
$node
->
put
(
$data
);
}
catch
(
\
OCP\Files\StorageNotAvailableException
$e
)
{
...
...
lib/private/connector/sabre/objecttree.php
View file @
75e8b398
...
...
@@ -71,7 +71,9 @@ class ObjectTree extends \Sabre\DAV\ObjectTree {
if
(
pathinfo
(
$path
,
PATHINFO_EXTENSION
)
===
'part'
)
{
// read from storage
$absPath
=
$this
->
fileView
->
getAbsolutePath
(
$path
);
list
(
$storage
,
$internalPath
)
=
Filesystem
::
resolvePath
(
'/'
.
$absPath
);
$mount
=
$this
->
fileView
->
getMount
(
$path
);
$storage
=
$mount
->
getStorage
();
$internalPath
=
$mount
->
getInternalPath
(
$absPath
);
if
(
$storage
)
{
/**
* @var \OC\Files\Storage\Storage $storage
...
...
@@ -79,7 +81,7 @@ class ObjectTree extends \Sabre\DAV\ObjectTree {
$scanner
=
$storage
->
getScanner
(
$internalPath
);
// get data directly
$data
=
$scanner
->
getData
(
$internalPath
);
$info
=
new
FileInfo
(
$absPath
,
$storage
,
$internalPath
,
$data
);
$info
=
new
FileInfo
(
$absPath
,
$storage
,
$internalPath
,
$data
,
$mount
);
}
else
{
$info
=
null
;
}
...
...
lib/private/files/fileinfo.php
View file @
75e8b398
...
...
@@ -29,15 +29,24 @@ class FileInfo implements \OCP\Files\FileInfo, \ArrayAccess {
*/
private
$internalPath
;
/**
* @var \OCP\Files\Mount\IMountPoint
*/
private
$mount
;
/**
* @param string|boolean $path
* @param Storage\Storage $storage
* @param string $internalPath
* @param array $data
* @param \OCP\Files\Mount\IMountPoint $mount
*/
public
function
__construct
(
$path
,
$storage
,
$internalPath
,
$data
)
{
public
function
__construct
(
$path
,
$storage
,
$internalPath
,
$data
,
$mount
)
{
$this
->
path
=
$path
;
$this
->
storage
=
$storage
;
$this
->
internalPath
=
$internalPath
;
$this
->
data
=
$data
;
$this
->
mount
=
$mount
;
}
public
function
offsetSet
(
$offset
,
$value
)
{
...
...
@@ -208,6 +217,7 @@ class FileInfo implements \OCP\Files\FileInfo, \ArrayAccess {
/**
* Check if a file or folder is shared
*
* @return bool
*/
public
function
isShared
()
{
...
...
@@ -229,4 +239,13 @@ class FileInfo implements \OCP\Files\FileInfo, \ArrayAccess {
return
false
;
}
/**
* Get the mountpoint the file belongs to
*
* @return \OCP\Files\Mount\IMountPoint
*/
public
function
getMountPoint
()
{
return
$this
->
mount
;
}
}
lib/private/files/mount/mountpoint.php
View file @
75e8b398
...
...
@@ -20,9 +20,22 @@ class MountPoint implements IMountPoint {
protected
$storage
=
null
;
protected
$class
;
protected
$storageId
;
/**
* Configuration options for the storage backend
*
* @var array
*/
protected
$arguments
=
array
();
protected
$mountPoint
;
/**
* Mount specific options
*
* @var array
*/
protected
$mountOptions
=
array
();
/**
* @var \OC\Files\Storage\StorageFactory $loader
*/
...
...
@@ -31,10 +44,11 @@ class MountPoint implements IMountPoint {
/**
* @param string|\OC\Files\Storage\Storage $storage
* @param string $mountpoint
* @param array $arguments (optional)
\
* @param array $arguments (optional)
configuration for the storage backend
* @param \OCP\Files\Storage\IStorageFactory $loader
* @param array $mountOptions mount specific options
*/
public
function
__construct
(
$storage
,
$mountpoint
,
$arguments
=
null
,
$loader
=
null
)
{
public
function
__construct
(
$storage
,
$mountpoint
,
$arguments
=
null
,
$loader
=
null
,
$mountOptions
=
null
)
{
if
(
is_null
(
$arguments
))
{
$arguments
=
array
();
}
...
...
@@ -44,6 +58,10 @@ class MountPoint implements IMountPoint {
$this
->
loader
=
$loader
;
}
if
(
!
is_null
(
$mountOptions
))
{
$this
->
mountOptions
=
$mountOptions
;
}
$mountpoint
=
$this
->
formatPath
(
$mountpoint
);
if
(
$storage
instanceof
Storage
)
{
$this
->
class
=
get_class
(
$storage
);
...
...
@@ -161,4 +179,15 @@ class MountPoint implements IMountPoint {
public
function
wrapStorage
(
$wrapper
)
{
$this
->
storage
=
$wrapper
(
$this
->
mountPoint
,
$this
->
getStorage
());
}
/**
* Get a mount option
*
* @param string $name Name of the mount option to get
* @param mixed $default Default value for the mount option
* @return mixed
*/
public
function
getOption
(
$name
,
$default
)
{
return
isset
(
$this
->
mountOptions
[
$name
])
?
$this
->
mountOptions
[
$name
]
:
$default
;
}
}
lib/private/files/node/node.php
View file @
75e8b398
...
...
@@ -288,4 +288,8 @@ class Node implements \OCP\Files\Node, FileInfo {
public
function
isEncrypted
()
{
return
$this
->
getFileInfo
()
->
isEncrypted
();
}
public
function
getMountPoint
()
{
return
$this
->
getFileInfo
()
->
getMountPoint
();
}
}
lib/private/files/view.php
View file @
75e8b398
...
...
@@ -112,6 +112,19 @@ class View {
return
Filesystem
::
getMountPoint
(
$this
->
getAbsolutePath
(
$path
));
}
/**
* get the mountpoint of the storage object for a path
* ( note: because a storage is not always mounted inside the fakeroot, the
* returned mountpoint is relative to the absolute root of the filesystem
* and doesn't take the chroot into account )
*
* @param string $path
* @return \OCP\Files\Mount\IMountPoint
*/
public
function
getMount
(
$path
)
{
return
Filesystem
::
getMountManager
()
->
find
(
$this
->
getAbsolutePath
(
$path
));
}
/**
* resolve a path to a storage and internal path
*
...
...
@@ -943,7 +956,7 @@ class View {
$data
=
\
OC_FileProxy
::
runPostProxies
(
'getFileInfo'
,
$path
,
$data
);
return
new
FileInfo
(
$path
,
$storage
,
$internalPath
,
$data
);
return
new
FileInfo
(
$path
,
$storage
,
$internalPath
,
$data
,
$mount
);
}
/**
...
...
@@ -960,8 +973,10 @@ class View {
return
$result
;
}
$path
=
$this
->
getAbsolutePath
(
$directory
);
/** @var \OC\Files\Storage\Storage $storage */
list
(
$storage
,
$internalPath
)
=
$this
->
resolvePath
(
$directory
);
$path
=
Filesystem
::
normalizePath
(
$path
);
$mount
=
$this
->
getMount
(
$directory
);
$storage
=
$mount
->
getStorage
();
$internalPath
=
$mount
->
getInternalPath
(
$path
);
if
(
$storage
)
{
$cache
=
$storage
->
getCache
(
$internalPath
);
$user
=
\
OC_User
::
getUser
();
...
...
@@ -995,7 +1010,7 @@ class View {
if
(
\
OCP\Util
::
isSharingDisabledForUser
())
{
$content
[
'permissions'
]
=
$content
[
'permissions'
]
&
~
\
OCP\Constants
::
PERMISSION_SHARE
;
}
$files
[]
=
new
FileInfo
(
$path
.
'/'
.
$content
[
'name'
],
$storage
,
$content
[
'path'
],
$content
);
$files
[]
=
new
FileInfo
(
$path
.
'/'
.
$content
[
'name'
],
$storage
,
$content
[
'path'
],
$content
,
$mount
);
}
//add a folder for any mountpoint in this directory and add the sizes of other mountpoints to the folders
...
...
@@ -1003,7 +1018,7 @@ class View {
$dirLength
=
strlen
(
$path
);
foreach
(
$mounts
as
$mount
)
{
$mountPoint
=
$mount
->
getMountPoint
();
$subStorage
=
Filesystem
::
getStorage
(
$mountPoint
);
$subStorage
=
$mount
->
getStorage
(
);
if
(
$subStorage
)
{
$subCache
=
$subStorage
->
getCache
(
''
);
...
...
@@ -1049,7 +1064,7 @@ class View {
$content
[
'permissions'
]
=
$content
[
'permissions'
]
&
~
\
OCP\Constants
::
PERMISSION_SHARE
;
}
$files
[]
=
new
FileInfo
(
$path
.
'/'
.
$rootEntry
[
'name'
],
$subStorage
,
''
,
$rootEntry
);
$files
[]
=
new
FileInfo
(
$path
.
'/'
.
$rootEntry
[
'name'
],
$subStorage
,
''
,
$rootEntry
,
$mount
);
}
}
}
...
...
@@ -1159,8 +1174,9 @@ class View {
$files
=
array
();
$rootLength
=
strlen
(
$this
->
fakeRoot
);
$mountPoint
=
Filesystem
::
getMountPoint
(
$this
->
fakeRoot
);
$storage
=
Filesystem
::
getStorage
(
$mountPoint
);
$mount
=
$this
->
getMount
(
''
);
$mountPoint
=
$mount
->
getMountPoint
();
$storage
=
$mount
->
getStorage
();
if
(
$storage
)
{
$cache
=
$storage
->
getCache
(
''
);
...
...
@@ -1170,13 +1186,14 @@ class View {
$internalPath
=
$result
[
'path'
];
$path
=
$mountPoint
.
$result
[
'path'
];
$result
[
'path'
]
=
substr
(
$mountPoint
.
$result
[
'path'
],
$rootLength
);
$files
[]
=
new
FileInfo
(
$path
,
$storage
,
$internalPath
,
$result
);
$files
[]
=
new
FileInfo
(
$path
,
$storage
,
$internalPath
,
$result
,
$mount
);
}
}
$mountPoints
=
Filesystem
::
getMountPoints
(
$this
->
fakeRoot
);
foreach
(
$mountPoints
as
$mountPoint
)
{
$storage
=
Filesystem
::
getStorage
(
$mountPoint
);
$mounts
=
Filesystem
::
getMountManager
()
->
findIn
(
$this
->
fakeRoot
);
foreach
(
$mounts
as
$mount
)
{
$mountPoint
=
$mount
->
getMountPoint
();
$storage
=
$mount
->
getStorage
();
if
(
$storage
)
{
$cache
=
$storage
->
getCache
(
''
);
...
...
@@ -1187,7 +1204,7 @@ class View {
$internalPath
=
$result
[
'path'
];
$result
[
'path'
]
=
rtrim
(
$relativeMountPoint
.
$result
[
'path'
],
'/'
);
$path
=
rtrim
(
$mountPoint
.
$internalPath
,
'/'
);
$files
[]
=
new
FileInfo
(
$path
,
$storage
,
$internalPath
,
$result
);
$files
[]
=
new
FileInfo
(
$path
,
$storage
,
$internalPath
,
$result
,
$mount
);
}
}
}
...
...
lib/private/preview.php
View file @
75e8b398
...
...
@@ -922,6 +922,11 @@ class Preview {
return
false
;
}
$mount
=
$file
->
getMountPoint
();
if
(
$mount
and
!
$mount
->
getOption
(
'previews'
,
true
)){
return
false
;
}
//check if there are preview backends
if
(
empty
(
self
::
$providers
))
{
self
::
initProviders
();
...
...
lib/public/files/fileinfo.php
View file @
75e8b398
...
...
@@ -169,4 +169,11 @@ interface FileInfo {
* @return bool
*/
public
function
isMounted
();
/**
* Get the mountpoint the file belongs to
*
* @return \OCP\Files\Mount\IMountPoint
*/
public
function
getMountPoint
();
}
lib/public/files/mount/imountpoint.php
View file @
75e8b398
...
...
@@ -55,4 +55,13 @@ interface IMountPoint {
* @param callable $wrapper
*/
public
function
wrapStorage
(
$wrapper
);
/**
* Get a mount option
*
* @param string $name Name of the mount option to get
* @param mixed $default Default value for the mount option
* @return mixed
*/
public
function
getOption
(
$name
,
$default
);
}
tests/lib/connector/sabre/file.php
View file @
75e8b398
...
...
@@ -24,7 +24,7 @@ class Test_OC_Connector_Sabre_File extends \Test\TestCase {
$info
=
new
\
OC\Files\FileInfo
(
'/test.txt'
,
null
,
null
,
array
(
'permissions'
=>
\
OCP\Constants
::
PERMISSION_ALL
));
)
,
null
);
$file
=
new
OC_Connector_Sabre_File
(
$view
,
$info
);
...
...
@@ -59,7 +59,7 @@ class Test_OC_Connector_Sabre_File extends \Test\TestCase {
$info
=
new
\
OC\Files\FileInfo
(
'/test.txt'
,
null
,
null
,
array
(
'permissions'
=>
\
OCP\Constants
::
PERMISSION_ALL
));
)
,
null
);
$file
=
new
OC_Connector_Sabre_File
(
$view
,
$info
);
...
...
@@ -83,7 +83,7 @@ class Test_OC_Connector_Sabre_File extends \Test\TestCase {
$info
=
new
\
OC\Files\FileInfo
(
'/super*star.txt'
,
null
,
null
,
array
(
'permissions'
=>
\
OCP\Constants
::
PERMISSION_ALL
));
)
,
null
);
$file
=
new
OC_Connector_Sabre_File
(
$view
,
$info
);
// action
...
...
@@ -104,7 +104,7 @@ class Test_OC_Connector_Sabre_File extends \Test\TestCase {
$info
=
new
\
OC\Files\FileInfo
(
'/super*star.txt'
,
null
,
null
,
array
(
'permissions'
=>
\
OCP\Constants
::
PERMISSION_ALL
));
)
,
null
);
$file
=
new
OC_Connector_Sabre_File
(
$view
,
$info
);
$file
->
setName
(
'/super*star.txt'
);
}
...
...
@@ -136,7 +136,7 @@ class Test_OC_Connector_Sabre_File extends \Test\TestCase {
$info
=
new
\
OC\Files\FileInfo
(
'/test.txt'
,
null
,
null
,
array
(
'permissions'
=>
\
OCP\Constants
::
PERMISSION_ALL
));
)
,
null
);
$file
=
new
OC_Connector_Sabre_File
(
$view
,
$info
);
...
...
@@ -158,7 +158,7 @@ class Test_OC_Connector_Sabre_File extends \Test\TestCase {
$info
=
new
\
OC\Files\FileInfo
(
'/test.txt'
,
null
,
null
,
array
(
'permissions'
=>
\
OCP\Constants
::
PERMISSION_ALL
));
)
,
null
);
$file
=
new
OC_Connector_Sabre_File
(
$view
,
$info
);
...
...
@@ -176,7 +176,7 @@ class Test_OC_Connector_Sabre_File extends \Test\TestCase {
$info
=
new
\
OC\Files\FileInfo
(
'/test.txt'
,
null
,
null
,
array
(
'permissions'
=>
0
));
)
,
null
);
$file
=
new
OC_Connector_Sabre_File
(
$view
,
$info
);
...
...
@@ -199,7 +199,7 @@ class Test_OC_Connector_Sabre_File extends \Test\TestCase {
$info
=
new
\
OC\Files\FileInfo
(
'/test.txt'
,
null
,
null
,
array
(
'permissions'
=>
\
OCP\Constants
::
PERMISSION_ALL
));
)
,
null
);
$file
=
new
OC_Connector_Sabre_File
(
$view
,
$info
);
...
...
tests/lib/connector/sabre/objecttree.php
View file @
75e8b398
...
...
@@ -101,7 +101,7 @@ class ObjectTree extends \Test\TestCase {
private
function
moveTest
(
$source
,
$dest
,
$updatables
,
$deletables
)
{
$view
=
new
TestDoubleFileView
(
$updatables
,
$deletables
);
$info
=
new
FileInfo
(
''
,
null
,
null
,
array
());
$info
=
new
FileInfo
(
''
,
null
,
null
,
array
()
,
null
);
$rootDir
=
new
OC_Connector_Sabre_Directory
(
$view
,
$info
);
$objectTree
=
$this
->
getMock
(
'\OC\Connector\Sabre\ObjectTree'
,
...
...
tests/lib/files/node/file.php
View file @
75e8b398
...
...
@@ -22,7 +22,7 @@ class File extends \Test\TestCase {
}
protected
function
getFileInfo
(
$data
)
{
return
new
FileInfo
(
''
,
null
,
''
,
$data
);
return
new
FileInfo
(
''
,
null
,
''
,
$data
,
null
);
}
public
function
testDelete
()
{
...
...
tests/lib/files/node/folder.php
View file @
75e8b398
...
...
@@ -25,7 +25,7 @@ class Folder extends \Test\TestCase {
}
protected
function
getFileInfo
(
$data
)
{
return
new
FileInfo
(
''
,
null
,
''
,
$data
);
return
new
FileInfo
(
''
,
null
,
''
,
$data
,
null
);
}
public
function
testDelete
()
{
...
...
tests/lib/files/node/node.php
View file @
75e8b398
...
...
@@ -19,7 +19,7 @@ class Node extends \Test\TestCase {
}
protected
function
getFileInfo
(
$data
)
{
return
new
FileInfo
(
''
,
null
,
''
,
$data
);
return
new
FileInfo
(
''
,
null
,
''
,
$data
,
null
);
}
public
function
testStat
()
{
...
...
tests/lib/files/node/root.php
View file @
75e8b398
...
...
@@ -21,7 +21,7 @@ class Root extends \Test\TestCase {
}
protected
function
getFileInfo
(
$data
)
{
return
new
FileInfo
(
''
,
null
,
''
,
$data
);
return
new
FileInfo
(
''
,
null
,
''
,
$data
,
null
);
}
public
function
testGet
()
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment