distinguish between touch and write

This commit is contained in:
Björn Schießle 2013-03-07 15:51:44 +01:00
parent 70f0e0a8da
commit 48bb53030c
3 changed files with 16 additions and 1 deletions

View File

@ -21,6 +21,12 @@ class Hooks {
if(\OCP\Config::getSystemValue('files_versions', Storage::DEFAULTENABLED)=='true') {
$path = $params[\OC\Files\Filesystem::signal_param_path];
$pos = strrpos($path, '.part');
if ($pos) {
error_log("old path: $path");
$path = substr($path, 0, $pos);
error_log("new path: $path");
}
if($path<>'') {
Storage::store($path);
}

View File

@ -107,6 +107,7 @@ class Storage {
// store a new version of a file
$users_view->copy('files'.$filename, 'files_versions'.$filename.'.v'.$users_view->filemtime('files'.$filename));
error_log("version created!");
$versionsSize = self::getVersionsSize($uid);
if ( $versionsSize === false || $versionsSize < 0 ) {
$versionsSize = self::calculateSize($uid);

View File

@ -245,7 +245,14 @@ class View {
if (!is_null($mtime) and !is_numeric($mtime)) {
$mtime = strtotime($mtime);
}
return $this->basicOperation('touch', $path, array('write'), $mtime);
$hooks = array('touch');
if (!$this->file_exists($path)) {
$hooks[] = 'write';
}
return $this->basicOperation('touch', $path, $hooks, $mtime);
}
public function file_get_contents($path) {
@ -596,6 +603,7 @@ class View {
if ($path == null) {
return false;
}
foreach ($hooks as $h) if ($h == "write") error_log("write triggered by $operation for $path");
$run = $this->runHooks($hooks, $path);
list($storage, $internalPath) = Filesystem::resolvePath($absolutePath . $postFix);
if ($run and $storage) {