Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 13 additions & 5 deletions apps/files_versions/lib/Storage.php
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,6 @@ private static function getVersionsSize($user) {
* store a new version of a file.
*/
public static function store($filename) {

// if the file gets streamed we need to remove the .part extension
// to get the right target
$ext = pathinfo($filename, PATHINFO_EXTENSION);
Expand Down Expand Up @@ -357,7 +356,6 @@ public static function renameOrCopy($sourcePath, $targetPath, $operation) {
* @return bool
*/
public static function rollback(string $file, int $revision, IUser $user) {

// add expected leading slash
$filename = '/' . ltrim($file, '/');

Expand Down Expand Up @@ -495,11 +493,21 @@ public static function getVersions($uid, $filename, $userFullPath = '') {
$filename = $pathparts['filename'];
if ($filename === $versionedFile) {
$pathparts = pathinfo($entryName);
$timestamp = substr($pathparts['extension'], 1);
$timestamp = substr($pathparts['extension'] ?? '', 1);
if (!is_numeric($timestamp)) {
\OC::$server->get(LoggerInterface::class)->error(
'Version file {path} has incorrect name format',
[
'path' => $entryName,
'app' => 'files_versions',
]
);
continue;
}
$filename = $pathparts['filename'];
$key = $timestamp . '#' . $filename;
$versions[$key]['version'] = $timestamp;
$versions[$key]['humanReadableTimestamp'] = self::getHumanReadableTimestamp($timestamp);
$versions[$key]['humanReadableTimestamp'] = self::getHumanReadableTimestamp((int)$timestamp);
if (empty($userFullPath)) {
$versions[$key]['preview'] = '';
} else {
Expand Down Expand Up @@ -577,7 +585,7 @@ public static function expireOlderThanMaxForUser($uid) {
* @param int $timestamp
* @return string for example "5 days ago"
*/
private static function getHumanReadableTimestamp($timestamp) {
private static function getHumanReadableTimestamp(int $timestamp): string {
$diff = time() - $timestamp;

if ($diff < 60) { // first minute
Expand Down