Skip to content

Conversation

@prateekmedia-alt
Copy link

@prateekmedia-alt prateekmedia-alt commented Feb 10, 2026

Summary

  • add GET /files/public-magic-metadata?fileID=&collectionID= to return the latest file object for that file+collection (including pubMagicMetadata) when caller has access
  • on client 409 from PUT /files/public-magic-metadata, fetch latest data for only the conflicted file(s), refresh local state, and retry once
  • keep optimistic local metadata/version updates only after successful write

Why

Editing caption during/just-after backup can hit metadata version conflicts (409).
Previously the client triggered a full silent sync before retrying, which is expensive.
This changes recovery to a targeted fetch for the specific file+collection and retries once.

Validation

  • dart format on changed Dart files
  • flutter analyze lib/gateways/files/file_magic_gateway.dart lib/services/file_magic_service.dart
  • gofmt on changed Go files
  • go test ./pkg/api ./pkg/controller ./pkg/repo

Notes

  • Full go test ./... fails in pkg/repo/storagebonus in local non-test environment with: Not running tests in non-test environment (pre-existing env guard).

@prateekmedia-alt prateekmedia-alt changed the title fix(photos): handle public magic metadata 409 on caption edits [mob][photos] handle public magic metadata 409 on caption edits Feb 10, 2026
e,
s,
);
await RemoteSyncService.instance.sync(silently: true);
Copy link
Member

Choose a reason for hiding this comment

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

I think this will wait for upload to finish. For now, either we can ignore this or build api to fetch latest medatada for files that are out of sync

@prateekmedia-alt prateekmedia-alt changed the title [mob][photos] handle public magic metadata 409 on caption edits fix(photos): resolve caption 409 with targeted public-metadata refresh Feb 10, 2026

// GetPublicMagicMetadata returns latest public magic metadata for a single file
// in a given collection if caller has access.
func (h *FileHandler) GetPublicMagicMetadata(c *gin.Context) {
Copy link
Member

Choose a reason for hiding this comment

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

Let's change it to return the File object? We will be able to reuse this API for other cases as well in future if needed.

@prateekmedia prateekmedia changed the title fix(photos): resolve caption 409 with targeted public-metadata refresh [mob][photos] resolve caption before sync Feb 10, 2026
Comment on lines 74 to 83
if (e.response?.statusCode != 409) {
rethrow;
}

_logger.warning(
"conflict while syncing public magic metadata, fetching latest metadata and retrying once",
e,
s,
);
await _refreshPublicMetadataFromServer(files);
Copy link
Member

Choose a reason for hiding this comment

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

Let's only try to patch if when only single file is getting updated? For bulk update, this can take way too long if we try to update for each image. Another option is that we create new endpoint for update, and, the new endpoint will return list of fileIDs that are out of sync. If we are just patching for caption, restricting to single file would more sense,

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.

3 participants