Skip to content

Commit

Permalink
Dont update again if mtime is to be updated,
Browse files Browse the repository at this point in the history
use target storage update instead
  • Loading branch information
mrow4a committed Jun 25, 2018
1 parent 5557eb4 commit 85a5166
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 23 deletions.
49 changes: 26 additions & 23 deletions apps/dav/lib/Connector/Sabre/File.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,30 @@ public function __construct($view, $info, $shareManager = null, Request $request
}
parent::__construct($view, $info, $shareManager);
}


/**
* Handles metadata updates for the target storage (mtime, propagation)
*
* @param Storage $targetStorage
* @param $targetInternalPath
*/
private function handleMetadataUpdate(\OC\Files\Storage\Storage $targetStorage, $targetInternalPath) {
// since we skipped the view we need to scan and emit the hooks ourselves

// allow sync clients to send the mtime along in a header
if (isset($this->request->server['HTTP_X_OC_MTIME'])) {
$mtime = $this->sanitizeMtime(
$this->request->server ['HTTP_X_OC_MTIME']
);
if ($targetStorage->touch($targetInternalPath, $mtime)) {
$this->header('X-OC-MTime: accepted');
}
$targetStorage->getUpdater()->update($targetInternalPath, $mtime);
} else {
$targetStorage->getUpdater()->update($targetInternalPath);
}
}

/**
* Updates the data
*
Expand Down Expand Up @@ -234,23 +257,14 @@ public function put($data) {
}
}

// since we skipped the view we need to scan and emit the hooks ourselves
$storage->getUpdater()->update($internalPath);
$this->handleMetadataUpdate($storage, $internalPath);

try {
$this->changeLock(ILockingProvider::LOCK_SHARED);
} catch (LockedException $e) {
throw new FileLocked($e->getMessage(), $e->getCode(), $e);
}

// allow sync clients to send the mtime along in a header
if (isset($this->request->server['HTTP_X_OC_MTIME'])) {
$mtime = $this->sanitizeMtime($this->request->server ['HTTP_X_OC_MTIME']);
if ($this->fileView->touch($this->path, $mtime)) {
$this->header('X-OC-MTime: accepted');
}
}

if ($view) {
$this->emitPostHooks($exists);
}
Expand Down Expand Up @@ -539,18 +553,7 @@ private function createFileChunked($data) {
$chunk_handler->file_assemble($targetStorage, $targetInternalPath);
}

// allow sync clients to send the mtime along in a header
if (isset($this->request->server['HTTP_X_OC_MTIME'])) {
$mtime = $this->sanitizeMtime(
$this->request->server ['HTTP_X_OC_MTIME']
);
if ($targetStorage->touch($targetInternalPath, $mtime)) {
$this->header('X-OC-MTime: accepted');
}
}

// since we skipped the view we need to scan and emit the hooks ourselves
$targetStorage->getUpdater()->update($targetInternalPath);
$this->handleMetadataUpdate($targetStorage, $targetInternalPath);

$this->fileView->changeLock($targetPath, ILockingProvider::LOCK_SHARED);

Expand Down
2 changes: 2 additions & 0 deletions apps/dav/lib/Connector/Sabre/Node.php
Original file line number Diff line number Diff line change
Expand Up @@ -368,6 +368,8 @@ public function releaseLock($type) {

/**
* @param int $type \OCP\Lock\ILockingProvider::LOCK_SHARED or \OCP\Lock\ILockingProvider::LOCK_EXCLUSIVE
*
* @throws \OCP\Lock\LockedException
*/
public function changeLock($type) {
$this->fileView->changeLock($this->path, $type);
Expand Down

0 comments on commit 85a5166

Please sign in to comment.