Skip to content

Commit 741752f

Browse files
blizzzbackportbot[bot]
authored andcommitted
fix(files_version): mtime confusion on milliseconds
fix(files_version): mtime confusion on milliseconds Co-authored-by: Ferdinand Thiessen <opensource@fthiessen.de> Signed-off-by: Arthur Schiwon <blizzz@arthur-schiwon.de> [skip ci]
1 parent c11085a commit 741752f

2 files changed

Lines changed: 4 additions & 2 deletions

File tree

apps/files_versions/src/utils/versions.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,9 +98,11 @@ export async function restoreVersion(version: Version) {
9898
*/
9999
function formatVersion(version: Required<FileStat>, node: INode): Version {
100100
const mtime = Date.parse(version.lastmod)
101+
// server timestamps are seconds-based, we have to nullify the milliseconds
102+
const nodeNormalizedMtime = Math.floor((node.mtime?.getTime() ?? 0) / 1000) * 1000
101103

102104
let previewUrl: string
103-
if (mtime === node.mtime?.getTime()) { // Version is the current one
105+
if (mtime === nodeNormalizedMtime) { // Version is the current one
104106
previewUrl = generateUrl('/core/preview?fileId={fileId}&c={fileEtag}&x=250&y=250&forceIcon=0&a=0&forceIcon=1&mimeFallback=1', {
105107
fileId: node.id,
106108
fileEtag: node.attributes.etag,

apps/files_versions/src/views/FilesVersionsSidebarTab.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ const loading = ref(false)
7373
const showVersionLabelForm = ref(false)
7474
const editedVersion = ref<Version | null>(null)
7575
76-
const currentVersionMtime = computed(() => props.node?.mtime?.getTime() ?? 0)
76+
const currentVersionMtime = computed(() => Math.floor(new Date(props.node?.mtime?.getTime() ?? 0).getTime() / 1000) * 1000)
7777
7878
/**
7979
* Order versions by mtime.

0 commit comments

Comments
 (0)