Skip to content

Commit

Permalink
Merge pull request #49284 from nextcloud/backport/49225/stable30
Browse files Browse the repository at this point in the history
[stable30] fix(files): ensure valid mtime and fallback to crtime if defined
  • Loading branch information
AndyScherzinger authored Feb 4, 2025
2 parents 63ca2d4 + 9404ade commit 6cac474
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 4 deletions.
16 changes: 15 additions & 1 deletion apps/files/src/components/FileEntry.vue
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,8 @@
class="files-list__row-mtime"
data-cy-files-list-row-mtime
@click="openDetailsIfAvailable">
<NcDateTime v-if="source.mtime" :timestamp="source.mtime" :ignore-seconds="true" />
<NcDateTime v-if="mtime" :timestamp="mtime" :ignore-seconds="true" />
<span v-else>{{ t('files', 'Unknown date') }}</span>
</td>

<!-- View columns -->
Expand Down Expand Up @@ -204,6 +205,19 @@ export default defineComponent({
}
},

mtime() {
// If the mtime is not a valid date, return it as is
if (this.source.mtime && !isNaN(this.source.mtime.getDate())) {
return this.source.mtime
}

if (this.source.crtime && !isNaN(this.source.crtime.getDate())) {
return this.source.crtime
}

return null
},

mtimeTitle() {
if (this.source.mtime) {
return moment(this.source.mtime).format('LLL')
Expand Down
4 changes: 2 additions & 2 deletions dist/files-main.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/files-main.js.map

Large diffs are not rendered by default.

0 comments on commit 6cac474

Please sign in to comment.