Skip to content

Fix import replace for file objects, archive state, and metadata#2957

Open
stevelr wants to merge 1 commit intoanyproto:developfrom
stevelr:fix/import-replace-003
Open

Fix import replace for file objects, archive state, and metadata#2957
stevelr wants to merge 1 commit intoanyproto:developfrom
stevelr:fix/import-replace-003

Conversation

@stevelr
Copy link
Copy Markdown
Contributor

@stevelr stevelr commented Feb 17, 2026

Description

During replace/update-existing import, three issues caused incorrect object targeting and metadata loss:

  1. ID resolution matched imported clones via OldAnytypeID instead of the original object. Prioritize direct object-ID lookup when getExisting is true to ensure in-place replace targets the correct object.

  2. File object re-upload could hit dedup and return a different file-object ID, bypassing state reset on the matched existing object. Short-circuit when the existing ID is already resolved.

  3. Archive/unarchive and file sync side-effects bump lastModifiedDate. Restore the snapshot's original timestamp after these operations. Also restore legacy file details (name, dates, creator) for both SmartBlockTypeFile snapshots and existing SmartBlockTypeFileObject objects during replace import.

Remove SmartBlockTypeFileObject from canUpdateObject exclusion list so file objects participate in resetState during replace. Change setArchived to bidirectional (archive and unarchive) and return whether an unarchive occurred for timestamp restoration.

Note: this PR changes some of the same files as two other PRs.

Recommended merge order to minimize rebase effort:

  1. Fix restore (import with UpdateExistingObjects) of archived object and existing object lookup #2955
  2. Enable backup and restore of custom properties and types #2956
  3. This one

  • I understand that contributing to this repository will require me to agree with the CLA

What type of PR is this? (check all applicable)

  • 🐛 Bug Fix
  • ✅ Test

Added tests?

  • 👍 yes

[optional] Are there any post-deployment tasks we need to perform?

See note above about merge order

During replace/update-existing import, three issues caused incorrect
object targeting and metadata loss:

1. ID resolution matched imported clones via OldAnytypeID instead of
the original object. Prioritize direct object-ID lookup when
getExisting is true to ensure in-place replace targets the correct
object.

2. File object re-upload could hit dedup and return a different
file-object ID, bypassing state reset on the matched existing
object. Short-circuit when the existing ID is already resolved.

3. Archive/unarchive and file sync side-effects bump
lastModifiedDate. Restore the snapshot's original timestamp after
these operations. Also restore legacy file details (name, dates,
creator) for both SmartBlockTypeFile snapshots and existing
SmartBlockTypeFileObject objects during replace import.

Remove SmartBlockTypeFileObject from canUpdateObject exclusion list
so file objects participate in resetState during replace. Change
setArchived to bidirectional (archive and unarchive) and return
whether an unarchive occurred for timestamp restoration.


Note: this PR changes some of the same files as two other PRs.

Recommended merge order to minimize rebase effort:

1. anyproto#2955
2. anyproto#2956
3. This one
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant