Skip to content
GitLab
Projects
Groups
Snippets
/
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
8a902d8f
Commit
8a902d8f
authored
Jun 17, 2012
by
Robin Appelman
Browse files
improve filecache support for smb
parent
a1fefea6
Changes
1
Hide whitespace changes
Inline
Side-by-side
apps/files_external/lib/smb.php
View file @
8a902d8f
...
...
@@ -47,6 +47,48 @@ class OC_FileStorage_SMB extends OC_FileStorage_StreamWrapper{
$path
=
substr
(
$path
,
0
,
-
1
);
}
return
'smb://'
.
$this
->
user
.
':'
.
$this
->
password
.
'@'
.
$this
->
host
.
$this
->
share
.
$this
->
root
.
$path
;
}
public
function
stat
(
$path
){
if
(
!
$path
and
$this
->
root
==
'/'
){
//mtime doesn't work for shares
$mtime
=
$this
->
shareMTime
();
$stat
=
stat
(
$this
->
constructUrl
(
$path
));
$stat
[
'mtime'
]
=
$mtime
;
return
$stat
;
}
else
{
return
stat
(
$this
->
constructUrl
(
$path
));
}
}
/**
* check if a file or folder has been updated since $time
* @param int $time
* @return bool
*/
public
function
hasUpdated
(
$path
,
$time
){
if
(
!
$path
and
$this
->
root
==
'/'
){
//mtime doesn't work for shares, but giving the nature of the backend, doing a full update is still just fast enough
return
true
;
}
else
{
$actualTime
=
$this
->
filemtime
(
$path
);
return
$actualTime
>
$time
;
}
}
/**
* get the best guess for the modification time of the share
*/
private
function
shareMTime
(){
$dh
=
$this
->
opendir
(
''
);
$lastCtime
=
0
;
while
(
$file
=
readdir
(
$dh
)){
if
(
$file
!=
'.'
and
$file
!=
'..'
){
$ctime
=
$this
->
filemtime
(
$file
);
if
(
$ctime
>
$lastCtime
){
$lastCtime
=
$ctime
;
}
}
}
return
$lastCtime
;
}
}
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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