distinguish between touch and write

remotes/origin/stable5
Björn Schießle 12 years ago
parent 70f0e0a8da
commit 48bb53030c
  1. 6
      apps/files_versions/lib/hooks.php
  2. 1
      apps/files_versions/lib/versions.php
  3. 10
      lib/files/view.php

@ -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);
}

@ -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);

@ -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) {

Loading…
Cancel
Save