Skip to content

Commit

Permalink
Fix timestamp detection on external FTP
Browse files Browse the repository at this point in the history
Context: #31510
Signed-off-by: Daniel Kesselberg <mail@danielkesselberg.de>
  • Loading branch information
solracsf authored and kesselb committed Nov 23, 2022
1 parent f635609 commit 34aa816
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions apps/files_external/lib/Lib/Storage/FTP.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,7 @@ public function __construct($params) {
$this->username = $params['user'];
$this->password = $params['password'];
if (isset($params['secure'])) {
if (is_string($params['secure'])) {
$this->secure = ($params['secure'] === 'true');
} else {
$this->secure = (bool)$params['secure'];
}
$this->secure = is_string($params['secure']) ? ($params['secure'] === 'true') : (bool) $params['secure'];
} else {
$this->secure = false;
}
Expand Down Expand Up @@ -355,10 +351,12 @@ public function getDirectoryContent($directory): \Traversable {

$data = [];
$data['mimetype'] = $isDir ? FileInfo::MIMETYPE_FOLDER : $mimeTypeDetector->detectPath($name);
$data['mtime'] = \DateTime::createFromFormat('YmdGis', $file['modify'])->getTimestamp();
if ($data['mtime'] === false) {
$modifyDate = \DateTime::createFromFormat('YmdGis', $file['modify']);
if ($modifyDate === false) {
$data['mtime'] = time();
}
} else {
$data['mtime'] = $modifyDate->getTimestamp();
}
if ($isDir) {
$data['size'] = -1; //unknown
} elseif (isset($file['size'])) {
Expand Down

0 comments on commit 34aa816

Please sign in to comment.