mirror of
https://github.com/nextcloud/server.git
synced 2026-05-28 04:32:30 -04:00
fix: modified touch function of the SFTP storage to update mtimes instead
Signed-off-by: Hendrik Leidinger <hendrik.leidinger@nextcloud.com>
This commit is contained in:
parent
b350164c3d
commit
88d3e0583a
1 changed files with 13 additions and 21 deletions
|
|
@ -333,10 +333,7 @@ class SFTP extends Common {
|
|||
$fh = fopen('sftpwrite://' . trim($absPath, '/'), 'w', false, $context);
|
||||
if ($fh) {
|
||||
$fh = CallbackWrapper::wrap($fh, null, null, function () use ($path): void {
|
||||
$mtime = time();
|
||||
$this->knownMTimes->set($path, $mtime);
|
||||
$this->getConnection()->touch($this->absPath($path), $mtime, $mtime);
|
||||
$this->getConnection()->clearStatCache();
|
||||
$this->touch($path, time());
|
||||
});
|
||||
}
|
||||
return $fh;
|
||||
|
|
@ -360,18 +357,17 @@ class SFTP extends Common {
|
|||
}
|
||||
|
||||
public function touch(string $path, ?int $mtime = null): bool {
|
||||
try {
|
||||
|
||||
$result = $this->getConnection()->touch($this->absPath($path), $mtime, $mtime);
|
||||
|
||||
if ($result) {
|
||||
$this->getConnection()->clearStatCache($this->absPath($path));
|
||||
if (!is_null($mtime)) {
|
||||
return false;
|
||||
$this->knownMTimes->set($path, $mtime);
|
||||
}
|
||||
if (!$this->file_exists($path)) {
|
||||
return $this->getConnection()->put($this->absPath($path), '');
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -432,10 +428,8 @@ class SFTP extends Common {
|
|||
public function file_put_contents(string $path, mixed $data): int|float|false {
|
||||
/** @psalm-suppress InternalMethod */
|
||||
$result = $this->getConnection()->put($this->absPath($path), $data);
|
||||
$mtime = time();
|
||||
$this->knownMTimes->set($path, $mtime);
|
||||
$this->getConnection()->touch($this->absPath($path), $mtime, $mtime);
|
||||
$this->getConnection()->clearStatCache();
|
||||
|
||||
$this->touch($path, time());
|
||||
|
||||
if ($result) {
|
||||
return strlen($data);
|
||||
|
|
@ -456,10 +450,8 @@ class SFTP extends Common {
|
|||
/** @psalm-suppress InternalMethod */
|
||||
$result = $this->getConnection()->put($this->absPath($path), $stream);
|
||||
fclose($stream);
|
||||
$mtime = time();
|
||||
$this->knownMTimes->set($path, $mtime);
|
||||
$this->getConnection()->touch($this->absPath($path), $mtime, $mtime);
|
||||
$this->getConnection()->clearStatCache();
|
||||
|
||||
$this->touch($path, time());
|
||||
|
||||
if ($result) {
|
||||
if ($size === null) {
|
||||
|
|
|
|||
Loading…
Reference in a new issue