Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions lib/private/Files/Storage/Local.php
Original file line number Diff line number Diff line change
Expand Up @@ -173,8 +173,16 @@ public function file_exists($path) {
}

public function filemtime($path) {
clearstatcache($this->getSourcePath($path));
return $this->file_exists($path) ? filemtime($this->getSourcePath($path)) : false;
$fullPath = $this->getSourcePath($path);
clearstatcache($fullPath);
if (!$this->file_exists($path)) {
return false;
}
if (PHP_INT_SIZE === 4) {
$helper = new \OC\LargeFileHelper();
return $helper->getFileMtime($fullPath);
}
return filemtime($fullPath);
}

public function touch($path, $mtime = null) {
Expand Down
18 changes: 18 additions & 0 deletions lib/private/LargeFileHelper.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<?php
/**
* @copyright Copyright (c) 2016, ownCloud, Inc.
* @copyright Copyright (c) 2016, Lukas Reschke <lukas@statuscode.ch>
*
* @author Andreas Fischer <bantu@owncloud.com>
* @author Lukas Reschke <lukas@statuscode.ch>
Expand Down Expand Up @@ -187,6 +188,23 @@ public function getFileSizeNative($filename) {
return $result;
}

/**
* Returns the current mtime for $fullPath
*
* @param string $fullPath
* @return int
*/
public function getFileMtime($fullPath) {
if (\OC_Helper::is_function_enabled('exec')) {
$os = strtolower(php_uname('s'));
if (strpos($os, 'linux') !== false) {
return $this->exec('stat -c %Y ' . escapeshellarg($fullPath));
}
}

return filemtime($fullPath);
}

protected function exec($cmd) {
$result = trim(exec($cmd));
return ctype_digit($result) ? 0 + $result : null;
Expand Down