Delete Avatar Problem #3952

Closed
opened 2025-11-02 05:31:36 -06:00 by GiteaMirror · 4 comments
Owner

Originally created by @jaqra on GitHub (Sep 13, 2019).

There is a problem something like this, reproduce:

  1. Create 2 organizations
  2. Set their avatars as same image
  3. Delete one organization

Then you will see other organization's avatar reset to default gitea avatar, becouse image removed from disk.

This is same:

  • Organization avatar
  • User avatar
  • Repository avatar

My opinions for solution:

  1. Check if there are other same avatar name before remote from disk
  2. Check if there are other same avatar name before set avatar and give new name if there
Originally created by @jaqra on GitHub (Sep 13, 2019). There is a problem something like this, reproduce: 1. Create 2 organizations 2. Set their avatars as **same** image 3. Delete one organization Then you will see other organization's avatar reset to default gitea avatar, becouse image removed from disk. This is same: - Organization avatar - User avatar - Repository avatar My opinions for solution: 1. Check if there are other same avatar name before remote from disk 2. Check if there are other same avatar name before set avatar and give new name if there
GiteaMirror added the issue/confirmedtype/bug labels 2025-11-02 05:31:36 -06:00
Author
Owner

@guillep2k commented on GitHub (Sep 13, 2019):

The filename is a hash of the avatar contents. For this, I think we should add the owner as part of the hash and force the names to be different. Otherwise, we'll have to keep a reference count for every file.

@guillep2k commented on GitHub (Sep 13, 2019): The filename is a hash of the avatar contents. For this, I think we should add the owner as part of the hash and force the names to be different. Otherwise, we'll have to keep a reference count for every file.
Author
Owner

@jaqra commented on GitHub (Sep 13, 2019):

IMHO First one does not affect? If a user add same image to multiple organization then remove one

@jaqra commented on GitHub (Sep 13, 2019): IMHO First one does not affect? If a user add same image to multiple organization then remove one
Author
Owner

@guillep2k commented on GitHub (Sep 13, 2019):

If your NASA organization adds planet.png as avatar, the file is uploaded as:

data/attachments/e/4/e4dc1049-68cd-4ed0-9636-41c0a04b0a69

The name is calculated by hashing its content. If ESA adds the same picture of a planet (no matter the file name, only the byte-by-byte content of the file), then it will be named again:

data/attachments/e/4/e4dc1049-68cd-4ed0-9636-41c0a04b0a69

That's why if ESA deletes its file, NASA's file gets deleted too. However, if we apply other metadata to the hash input, the hash will be different each case, for example:

NASA's planet.png       fe5156a4-6562-49a6-8732-1dbb48639560
ESA's planet.png        b519f855-1e11-4893-b64e-95ca221758cd

Even if they are the same file.

That should solve the problem, because if ESA deletes or changes its avatar, only b519f855-1e11-4893-b64e-95ca221758cd will be deleted, while fe5156a4-6562-49a6-8732-1dbb48639560 will remain untouched.

@guillep2k commented on GitHub (Sep 13, 2019): If your NASA organization adds `planet.png` as avatar, the file is uploaded as: ``` data/attachments/e/4/e4dc1049-68cd-4ed0-9636-41c0a04b0a69 ``` The name is calculated by hashing its content. If ESA adds the _same_ picture of a planet (no matter the file name, only the byte-by-byte content of the file), then it will be named again: ``` data/attachments/e/4/e4dc1049-68cd-4ed0-9636-41c0a04b0a69 ``` That's why if ESA deletes its file, NASA's file gets deleted too. However, if we apply other metadata to the hash input, the hash will be different each case, for example: ``` NASA's planet.png fe5156a4-6562-49a6-8732-1dbb48639560 ESA's planet.png b519f855-1e11-4893-b64e-95ca221758cd ``` Even if they are the same file. That should solve the problem, because if ESA deletes or changes its avatar, only `b519f855-1e11-4893-b64e-95ca221758cd` will be deleted, while `fe5156a4-6562-49a6-8732-1dbb48639560` will remain untouched.
Author
Owner

@stale[bot] commented on GitHub (Nov 13, 2019):

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs during the next 2 weeks. Thank you for your contributions.

@stale[bot] commented on GitHub (Nov 13, 2019): This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs during the next 2 weeks. Thank you for your contributions.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/gitea#3952