Skip to content

Conversation

@hrenard
Copy link

@hrenard hrenard commented Sep 30, 2022

Proposed changes (including videos or screenshots)

Delete current room's avatar before inserting the new one and not after. On store like S3, if we delete after the insertion then the object isn't available anymore on the storage.

Issue(s)

#22903
#15470
#26677

Steps to test or reproduce

  1. Enable S3 storage.
  2. Set a room's avatar and save.
  3. Set a new avatar and save.

The room has an empty avatar because S3 returns a 404.

Further comments

This is consistent with the way it's done in setUserAvatar:

const fileStore = FileUpload.getStore('Avatars');
fileStore.deleteByName(user.username);
const file = {
userId: user._id,
type,
size: buffer.length,
};
const result = fileStore.insertSync(file, buffer);
const avatarETag = etag || result?.etag || null;
Meteor.setTimeout(function () {
Users.setAvatarData(user._id, service, avatarETag);
api.broadcast('user.avatarUpdate', {
username: user.username,
avatarETag,
});
}, 500);

@engelgabriel engelgabriel added this to the 5.2.0 milestone Sep 30, 2022
@alvaropmello alvaropmello removed this from the 5.2.0 milestone Oct 3, 2022
@rodrigok rodrigok added this to the 5.2.1 milestone Oct 3, 2022
@gabriellsh
Copy link
Member

Hi @hrenard ! Thanks for contributing with your solution!

I think you changed the logic a little too much, though. Just deleting before upload should suffice.
I've opened a new PR with the ideal solution here #27060. Please, feel free to comment if you have any more suggestions. (Added you as co-author).

@gabriellsh gabriellsh closed this Oct 13, 2022
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.

5 participants