summaryrefslogtreecommitdiffstats
path: root/apps/files_external
diff options
context:
space:
mode:
authorRobin Appelman <robin@icewind.nl>2023-02-28 17:15:14 +0100
committerRobin Appelman <robin@icewind.nl>2023-03-30 17:44:47 +0200
commitfd0ef588b4d33871f82d5619432799477b88862e (patch)
tree560ba3bbb28ea721a4676348e4af64bbc6020e21 /apps/files_external
parent636c2415cc8b119c89af5b59d2a9457f87d7cf0d (diff)
downloadnextcloud-server-fd0ef588b4d33871f82d5619432799477b88862e.tar.gz
nextcloud-server-fd0ef588b4d33871f82d5619432799477b88862e.zip
fix ftp external storage with filezilla server
- filezilla doesn't like "" as parameter for `mdtm` (all others seem fine) - filezilla sends fractional modified date Signed-off-by: Robin Appelman <robin@icewind.nl>
Diffstat (limited to 'apps/files_external')
-rw-r--r--apps/files_external/lib/Lib/Storage/FTP.php12
-rw-r--r--apps/files_external/lib/Lib/Storage/FtpConnection.php10
2 files changed, 15 insertions, 7 deletions
diff --git a/apps/files_external/lib/Lib/Storage/FTP.php b/apps/files_external/lib/Lib/Storage/FTP.php
index ae02f37b575..623388048e7 100644
--- a/apps/files_external/lib/Lib/Storage/FTP.php
+++ b/apps/files_external/lib/Lib/Storage/FTP.php
@@ -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'])) {
diff --git a/apps/files_external/lib/Lib/Storage/FtpConnection.php b/apps/files_external/lib/Lib/Storage/FtpConnection.php
index c6f9a5c91b0..f183a5a52de 100644
--- a/apps/files_external/lib/Lib/Storage/FtpConnection.php
+++ b/apps/files_external/lib/Lib/Storage/FtpConnection.php
@@ -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) {