Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add option to prevent updating assets on import #69

Merged
Merged
Show file tree
Hide file tree
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
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Changelog

## Unreleased

### Adds

* Adds a `preventUpdateAssets` to the module that will not try to update already existing assets on import.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are right to want this to change, because it is doing a great deal of extra work, but the actual fix is different... attachments are immutable, except for crops, docIds and archivedDocIds. Therefore the file itself should never need to be re-uploaded, although some crops present in the imported database might need to be inserted, which I don't see happening in the existing code.

So I will discuss with the team, I think this would make more sense as a warranty issue in gitlab.

My fault perhaps for making attachments do so much complicated bookkeeping to avoid copies, but copies are very expensive when multiplied across all modes and locales.


## 2.1.1 (2024-06-21)

### Fixes
Expand Down
3 changes: 2 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@
i18n: {
ns: 'aposImportExport',
browser: true
}
},
preventUpdateAssets: false,

Check failure on line 21 in index.js

View workflow job for this annotation

GitHub Actions / build (16, 4.4)

Unexpected trailing comma

Check failure on line 21 in index.js

View workflow job for this annotation

GitHub Actions / build (16, 6.0)

Unexpected trailing comma
},
init(self) {
self.formats = {
Expand Down
2 changes: 1 addition & 1 deletion lib/methods/import.js
Original file line number Diff line number Diff line change
Expand Up @@ -622,7 +622,7 @@ module.exports = self => {
{ attachmentId: attachment._id }
);
} catch (err) {
if (err.message === 'duplicate') {
if (err.message === 'duplicate' && !self.options.preventUpdateAssets) {
await self.apos.attachment.update(
req,
file,
Expand Down
Loading