mirror of
https://github.com/nextcloud/server.git
synced 2026-05-25 02:34:12 -04:00
Merge pull request #36905 from nextcloud/ftp-fix-filezilla
fix ftp external storage with filezilla server
This commit is contained in:
commit
d6ff5d8ee5
2 changed files with 15 additions and 7 deletions
|
|
@ -123,7 +123,8 @@ class FTP extends Common {
|
|||
return $item['type'] === 'cdir';
|
||||
}));
|
||||
if ($currentDir) {
|
||||
$time = \DateTime::createFromFormat('YmdHis', $currentDir['modify'] ?? '');
|
||||
[$modify] = explode('.', $currentDir['modify'] ?? '', 2);
|
||||
$time = \DateTime::createFromFormat('YmdHis', $modify);
|
||||
if ($time === false) {
|
||||
throw new \Exception("Invalid date format for directory: $currentDir");
|
||||
}
|
||||
|
|
@ -355,10 +356,11 @@ class FTP extends Common {
|
|||
|
||||
$data = [];
|
||||
$data['mimetype'] = $isDir ? FileInfo::MIMETYPE_FOLDER : $mimeTypeDetector->detectPath($name);
|
||||
$data['mtime'] = \DateTime::createFromFormat('YmdGis', $file['modify'])->getTimestamp();
|
||||
if ($data['mtime'] === false) {
|
||||
$data['mtime'] = time();
|
||||
}
|
||||
|
||||
// strip fractional seconds
|
||||
[$modify] = explode('.', $file['modify'], 2);
|
||||
$mtime = \DateTime::createFromFormat('YmdGis', $modify);
|
||||
$data['mtime'] = $mtime === false ? time() : $mtime->getTimestamp();
|
||||
if ($isDir) {
|
||||
$data['size'] = -1; //unknown
|
||||
} elseif (isset($file['size'])) {
|
||||
|
|
|
|||
|
|
@ -89,8 +89,14 @@ class FtpConnection {
|
|||
return @ftp_rename($this->connection, $source, $target);
|
||||
}
|
||||
|
||||
public function mdtm(string $path) {
|
||||
return @ftp_mdtm($this->connection, $path);
|
||||
public function mdtm(string $path): int {
|
||||
$result = @ftp_mdtm($this->connection, $path);
|
||||
|
||||
// filezilla doesn't like empty path with mdtm
|
||||
if ($result === -1 && $path === "") {
|
||||
$result = @ftp_mdtm($this->connection, "/");
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
public function size(string $path) {
|
||||
|
|
|
|||
Loading…
Reference in a new issue