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

Playmaker doesn't update etag; therefore Fdroid thinks no repo update available #20

Open
Yannik opened this issue Feb 1, 2018 · 11 comments
Labels

Comments

@Yannik
Copy link

Yannik commented Feb 1, 2018

Hi,
I had the problem of the fdroid app keeping the same "last updated" date for my playmaker repository (and also not providing new app versions).
I debugged this and found the reason.

These are the headers returned by the playmaker repo when requesting index-v1.jar before updating the repo:

date: Thu, 01 Feb 2018 13:40:32 GMT
server: TornadoServer/4.5.3
strict-transport-security: max-age=31536000
content-type: application/java-archive
accept-ranges: bytes
etag: "4087f73ea76e66962006245fb4aa4ecb"
last-modified: Thu, 01 Feb 2018 12:27:21 GMT
content-length: 5489

Now I updated the repo and got these headers returned:

date: Thu, 01 Feb 2018 13:40:50 GMT
server: TornadoServer/4.5.3
strict-transport-security: max-age=31536000
content-type: application/java-archive
accept-ranges: bytes
etag: "4087f73ea76e66962006245fb4aa4ecb"
last-modified: Thu, 01 Feb 2018 13:40:46 GMT
content-length: 5494

You can clearly see that the last-modified header is updated correctly, but the etag stays the same.

This is a huge issue, as fdroid uses the etag to determine whether a repository needs to be updated or not: https://gitlab.com/fdroid/fdroidclient/blob/master/app/src/main/java/org/fdroid/fdroid/net/HttpDownloader.java#L95

@Yannik Yannik changed the title Playmaker doesn't update etag; therefore Fdroid thinks no update occured Playmaker doesn't update etag; therefore Fdroid thinks no repo update available Feb 1, 2018
@Yannik
Copy link
Author

Yannik commented Feb 1, 2018

Looking at http://www.tornadoweb.org/en/stable/_modules/tornado/web.html#RequestHandler.compute_etag, we can clearly see why it doesn't return anything useful.

Apache (see https://httpd.apache.org/docs/2.4/de/mod/core.html#fileetag) uses

INode
    The file's i-node number will be included in the calculation
MTime
    The date and time the file was last modified will be include
Size
    The number of bytes in the file will be included

to calculate the etag. I just tried using apache to serve the repo, it worked without issues. To fix this in playmaker, we should definitely use the modified datetime and size to calculate the etag. (I wouldn't use the inode to ensure persistent etags between docker deploys)

@NoMore201
Copy link
Owner

Thanks for reporting, I never noticed this problem. Need to check if there's a way in RequestHandler to get the filepath which is currently being served through tornado, so that we could use [1] and [2]

[1] https://docs.python.org/3/library/os.path.html#os.path.getmtime
[2] https://docs.python.org/3/library/os.path.html#os.path.getsize

@Yannik
Copy link
Author

Yannik commented Feb 1, 2018

@NoMore201 Look at this: https://gist.github.com/andreadipersio/7526464#file-tornado-disable-auto-etag-py-L12
Edit: Sorry, I misread your comment. Yes, there needs to be a way to get the filepath to correctly implement etag generation.

@j5k
Copy link

j5k commented Feb 2, 2018

I can report this problem too. Thanks for fixing.

@NoMore201 NoMore201 added the bug label Feb 2, 2018
@Yannik
Copy link
Author

Yannik commented Feb 15, 2018

@NoMore201 Any updates on this? :)

@apexo
Copy link

apexo commented Feb 21, 2018

A manual workaround in f-droid: disabling and re-enabling the repository in f-droid seems to force a refresh. This kind of defeats the purpose of automatic updates, but at least it is still possible to update apps.

@apexo
Copy link

apexo commented Feb 22, 2018

Also, when using a reverse proxy, it can be configured to hide the ETag, e.g. for nginx:

proxy_hide_header ETag;

@Yannik
Copy link
Author

Yannik commented Feb 22, 2018

@apexo I don't think that's useful, as fdroid will re-download the repo list every time, as it thinks it has changed.

@apexo
Copy link

apexo commented Feb 25, 2018

It's not a perfect solution, but at least you'll get updates.

@Yannik
Copy link
Author

Yannik commented May 31, 2018

Hey @NoMore201, have you abandoned this project? :-(

@Findus23
Copy link

@Yannik, @apexo

I just had an idea for an workaround (if you are using nginx in front of playmaker on the docker host)

As the fdroid repo is just tornado serving the fdroid/repo/ directory, you can completly circumvent playmaker and make nginx directly serve that directory (and therefore correctly report etags)

location /fdroid {
        alias /srv/fdroid/repo/;
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants