diff --git a/apps/files_external/lib/Lib/Storage/FTP.php b/apps/files_external/lib/Lib/Storage/FTP.php index ae02f37b5754b..727d4c3707bae 100644 --- a/apps/files_external/lib/Lib/Storage/FTP.php +++ b/apps/files_external/lib/Lib/Storage/FTP.php @@ -123,7 +123,8 @@ public function filemtime($path) { return $item['type'] === 'cdir'; })); if ($currentDir) { - $time = \DateTime::createFromFormat('YmdHis', $currentDir['modify'] ?? ''); + [$modify] = explode('.', $currentDir['modify'] ?? ''); + $time = \DateTime::createFromFormat('YmdHis', $modify); if ($time === false) { throw new \Exception("Invalid date format for directory: $currentDir"); } @@ -355,7 +356,10 @@ public function getDirectoryContent($directory): \Traversable { $data = []; $data['mimetype'] = $isDir ? FileInfo::MIMETYPE_FOLDER : $mimeTypeDetector->detectPath($name); - $data['mtime'] = \DateTime::createFromFormat('YmdGis', $file['modify'])->getTimestamp(); + + // strip fractional seconds + [$modify] = explode('.', $file['modify']); + $data['mtime'] = \DateTime::createFromFormat('YmdGis', $modify)->getTimestamp(); if ($data['mtime'] === false) { $data['mtime'] = time(); } diff --git a/apps/files_external/lib/Lib/Storage/FtpConnection.php b/apps/files_external/lib/Lib/Storage/FtpConnection.php index c6f9a5c91b02b..327d0c48b5b47 100644 --- a/apps/files_external/lib/Lib/Storage/FtpConnection.php +++ b/apps/files_external/lib/Lib/Storage/FtpConnection.php @@ -90,7 +90,13 @@ public function rename(string $source, string $target) { } public function mdtm(string $path) { - return @ftp_mdtm($this->connection, $path); + $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) {