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

404 for remote avatar #4071

Closed
johanfleury opened this issue May 10, 2021 · 9 comments
Closed

404 for remote avatar #4071

johanfleury opened this issue May 10, 2021 · 9 comments
Labels
Component: Federation 🎡 Type: Bug 🐛 Confirmed bug, at least replicated once by another contributor

Comments

@johanfleury
Copy link
Contributor

I suffered a data loss recently and restored PeerTube with an empty storage. Since then, some avatars are not showing and I couldn’t find any way to make PeerTube reload them (the files are not present in the data directory).

I had a similar issue with thumbnails, but unsubscribing from a channel then subscribing again fixed that (I had no luck trying to restore avatars with this technique).

Here is a screenshot that shows the issue:

Missing avatars on a user and their channel

The avatar URL returns a 404 status code:

$ curl -I -X GET https://peertube.br0.fr/lazy-static/avatars/2b8ff6f3-b4fd-45d0-9238-4dc28148c292.png
HTTP/2 404
date: Mon, 10 May 2021 16:16:27 GMT
content-length: 0
tk: N
access-control-allow-origin: *
strict-transport-security: max-age=15724800; includeSubDomains
permissions-policy: interest-cohort=()

And the avatar is not there:

$ ll avatars/2b8ff6f3-b4fd-45d0-9238-4dc28148c292.png
ls: cannot access 'avatars/2b8ff6f3-b4fd-45d0-9238-4dc28148c292.png': No such file or directory

The question is, is there a way to make PeerTube download a channel/user avatar when it’s not there?

If not, what would be the best solution? I’m thinking of two ways of doing this:

  • Detect when a remote user/channel avatar is missing on disk and fetch it then (for instance when PeerTube returns a 404 error).
  • Have a background job that checks avatars and fetch them when they are missing.

I could probably work on a PR if you want to.

@AnonymousWebHacker
Copy link

@johanfleury
Copy link
Contributor Author

Thanks for the suggestion, but unfortunately this script was added in 3.2-rc1 and I’m still running version 3.1 (the latest stable release).

Also, after having a quick look at the code, it seems that it’s not doing anything related to avatars, so I don’t think it would actually solve my issue.

@AnonymousWebHacker
Copy link

That was what I was going to tell you, I confused avatar with preview of the videos [thumbnails] :)
Actually, that problem has happened to me, I do not know if it is a problem with the ffmpeg or no idea what it may be, that it is an error that the avatars fail.
However, in what they give you an answer (I hope it does not delay)
You can take the ID of the missing avatar, go to / avatars / and copy any of the ones that are there and rename it with the missing ID.

@Chocobozzz
Copy link
Owner

Hello,

Could you enable debug logs and paste SQL lines before https://peertube.br0.fr/lazy-static/avatars/2b8ff6f3-b4fd-45d0-9238-4dc28148c292.png request in the logs?

@johanfleury
Copy link
Contributor Author

Here you are:

[peertube.br0.fr:443] 2021-06-01 23:14:37.964 debug: Executed SQL request - Executing (default): SELECT "id", "filename", "height", "width", "fileUrl", "onDisk", "type", "createdAt", "updatedAt" FROM "actorImage" AS "ActorImageModel" WHERE "ActorImageModel"."filename" = '2b8ff6f3-b4fd-45d0-9238-4dc28148c292.png' LIMIT 1;
[peertube.br0.fr:443] 2021-06-01 23:14:37.971 error: Error in controller. {
  "err": "Error: ENOENT: no such file or directory, stat '/data/avatars/2b8ff6f3-b4fd-45d0-9238-4dc28148c292.png'"
}
[peertube.br0.fr:443] 2021-06-01 23:14:37.985 info: 184.160.0.0 - - [01/Jun/2021:23:14:37 +0000] "GET /lazy-static/avatars/2b8ff6f3-b4fd-45d0-9238-4dc28148c292.png HTTP/1.1" 404 - "-" "Firefox"

@Chocobozzz
Copy link
Owner

Thanks, could you paste the output of the SQL query:

 SELECT "id", "filename", "height", "width", "fileUrl", "onDisk", "type", "createdAt", "updatedAt" FROM "actorImage" AS "ActorImageModel" WHERE "ActorImageModel"."filename" = '2b8ff6f3-b4fd-45d0-9238-4dc28148c292.png' LIMIT 1;

@johanfleury
Copy link
Contributor Author

johanfleury commented Jun 2, 2021

 id  |                 filename                 | height | width |                                      fileUrl                                       | onDisk | type |         createdAt          |         updatedAt
-----+------------------------------------------+--------+-------+------------------------------------------------------------------------------------+--------+------+----------------------------+----------------------------
 271 | 2b8ff6f3-b4fd-45d0-9238-4dc28148c292.png |        |       | https://indymotion.fr/lazy-static/avatars/b2f78a88-454a-49a2-a7dc-dabe3432a9a7.png | t      |    1 | 2020-12-23 15:28:35.187+00 | 2020-12-23 15:28:54.643+00

I see onDisk is set to true (which at some point was right but not anymore). I tried setting it to false but it didn’t work:

peertube=# UPDATE "actorImage" SET "onDisk" = '0' WHERE "filename" = '2b8ff6f3-b4fd-45d0-9238-4dc28148c292.png';
UPDATE 1
peertube=# SELECT "id", "filename", "height", "width", "fileUrl", "onDisk", "type", "createdAt", "updatedAt" FROM "actorImage" AS "ActorImageModel" WHERE "ActorImageModel"."filename" = '2b8ff6f3-b4fd-45d0-9238-4dc28148c292.png' LIMIT 1;
 id  |                 filename                 | height | width |                                      fileUrl                                       | onDisk | type |         createdAt          |         updatedAt
-----+------------------------------------------+--------+-------+------------------------------------------------------------------------------------+--------+------+----------------------------+----------------------------
 271 | 2b8ff6f3-b4fd-45d0-9238-4dc28148c292.png |        |       | https://indymotion.fr/lazy-static/avatars/b2f78a88-454a-49a2-a7dc-dabe3432a9a7.png | f      |    1 | 2020-12-23 15:28:35.187+00 | 2020-12-23 15:28:54.643+00
(1 row)
$ curl -I -X GET https://peertube.br0.fr/lazy-static/avatars/2b8ff6f3-b4fd-45d0-9238-4dc28148c292.png
HTTP/2 404
date: Wed, 02 Jun 2021 15:44:40 GMT
content-length: 0
x-frame-options: DENY
tk: N
access-control-allow-origin: *
strict-transport-security: max-age=15724800; includeSubDomains
permissions-policy: interest-cohort=()

@Chocobozzz Chocobozzz changed the title Is there a way to make PeerTube refresh avatars 404 for remote avatar Jun 8, 2021
@Chocobozzz Chocobozzz added Status: To Reproduce Likely a bug but needs reproduction and/or extended log from the issuer and removed Type: Question labels Jun 8, 2021
@johanfleury
Copy link
Contributor Author

@Chocobozzz I see you added the Status: To Reproduce label. I think the easiest way to do this is simply by removing the file from disk (that’s basically what happened to me, I started the instance with it’s existing DB on an empty disk).

@Chocobozzz Chocobozzz added Component: Federation 🎡 Type: Bug 🐛 Confirmed bug, at least replicated once by another contributor and removed Status: To Reproduce Likely a bug but needs reproduction and/or extended log from the issuer Status: Waiting for answer Waiting issue author answer labels Jun 14, 2021
@Chocobozzz
Copy link
Owner

Thanks, it should be fixed by 79db409

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Component: Federation 🎡 Type: Bug 🐛 Confirmed bug, at least replicated once by another contributor
Projects
None yet
Development

No branches or pull requests

3 participants