libpkgx icon indicating copy to clipboard operation
libpkgx copied to clipboard

Fix sync never ending when pantry is not updated in 24 hours

Open felipecrs opened this issue 1 year ago • 1 comments

To be clear, pkgx is completely broken by now because of this issue.

It turns out that the function that detects whether the sync was last synced recently isn't working properly, because it's relying on the mtime of the pantry/projects folder, which is set to its original mtime when downloaded by either git or tar.

This means the function would always detect outdated sync if there was no commit in the pantry repo in the last 24 hours.

This was just a quick way around it. Other solutions I tried:

  1. ctime (change time). This would work better, but Deno doesn't support it. (node does)

  2. tar's --touch to reset modification time, but it only works for files not for directories. Also, the pantry could have been downloaded with git.

PS: tests are failing but the code is working, and I'm using it in my fork. I will not bother fixing tests as apparently no one is merging code here anyway.

felipecrs avatar Jul 06 '24 22:07 felipecrs

@felipecrs that's a good find. i know main is currently a work-in-progress, and max's attention has been diverted for the moment. in the interim, i can schedule the ci.pantry.tgz.yml job to run at midnight, which should hopefully alleviate this until we decide on a proper solution.

jhheider avatar Jul 08 '24 00:07 jhheider

Tried to find how this would loop infinitely but couldn't see it so just decided to remove neglected altogether in #75 since it is dumb.

We force sync for all situations where a pkg might be newer than what we have locally already so this neglected check was overkill and dumb anyway.

mxcl avatar Sep 05 '24 19:09 mxcl

Tried to find how this would loop infinitely

Try to patch this line:

- return (Date.now() - stat.mtime.getTime()) > 24 * 60 * 60 * 1000
+ return (Date.now() - stat.mtime.getTime()) > 15 * 60 * 1000

And you should be able to reproduce it. As long as this time is longer than the time the pantry was updated for the last time, you should be able to reproduce it:

image

felipecrs avatar Sep 05 '24 21:09 felipecrs

As long as this time is longer than the time the pantry was updated for the last time

to that end, you can probable just take out all the multiplication. The pantry should always be older than now, so it should loop immediately.

jhheider avatar Sep 05 '24 21:09 jhheider

Ops, btw I meant "shorter", not "longer".

felipecrs avatar Sep 05 '24 21:09 felipecrs