fix: skip model size comparison in diff check (Blender compression changes size)

Models are always re-pushed server-side since Draco compression changes
the file size, making client/remote size comparison unreliable.
Textures are still compared by size (not compressed, reliable).
Client-side diff now only flags models as 'new' if absent from remote,
and never as 'changed' (server handles the actual push decision).
This commit is contained in:
Tom Boullay
2026-04-14 14:48:59 +02:00
parent 91eaa5d186
commit 3adcf9d30e
2 changed files with 39 additions and 29 deletions
+16 -18
View File
@@ -44,33 +44,31 @@ async function checkFolderDiffs(
const remoteFiles: { name: string; size: number }[] = data.files || []
const remoteMap = new Map(remoteFiles.map((f) => [f.name.toLowerCase(), f.size]))
// Build local file list with sizes
const localFiles: { name: string; size: number }[] = []
localFiles.push({
name: folder.modelFile.name,
size: folder.modelFile.size,
})
for (const tex of folder.textures) {
localFiles.push({
name: tex.name,
size: tex.file.size,
})
}
const diffs: FileDiff[] = []
const localNames = new Set<string>()
for (const local of localFiles) {
const key = local.name.toLowerCase()
// Model: skip size comparison (compression changes the size).
// We only check if it exists on remote or not.
const modelKey = folder.modelFile.name.toLowerCase()
localNames.add(modelKey)
if (!remoteMap.has(modelKey)) {
diffs.push({ name: folder.modelFile.name, status: 'new' })
}
// If model exists on remote → don't add to diffs (we can't know if it changed)
// Textures: compare by size (not compressed, so size is reliable)
for (const tex of folder.textures) {
const key = tex.name.toLowerCase()
localNames.add(key)
const remoteSize = remoteMap.get(key)
if (remoteSize === undefined) {
diffs.push({ name: local.name, status: 'new' })
} else if (remoteSize !== local.size) {
diffs.push({ name: local.name, status: 'changed' })
diffs.push({ name: tex.name, status: 'new' })
} else if (remoteSize !== tex.file.size) {
diffs.push({ name: tex.name, status: 'changed' })
}
}
// Files on remote but not in local → deleted
for (const [name] of remoteMap) {
if (!localNames.has(name)) {
diffs.push({ name, status: 'deleted' })