Closed Yonaba closed 10 years ago
Considering that the sha1sum of each file is stored in the src/games.json
it might make more sense to just store the byte length in there.
Then we don't have to deal with a bunch of http requests on the client side.
This may create one more point of failure for developers, but if we ever automate it, it should not be any problem at all.
Awesome.
I also thought the same at first. But I didn't know reliable it would be to save this information in the games.json
file. Since most of the .love files are hosted in different places, the one maintaining them may substitute the file with another, making the size stored in the game.json
outdated.
If all .love files were hosted in a single place however, with only one maintainer (i.e., you), this would be a straightforward, simple and safe solution, IMO.
That's why I proposed an automated way to get the file size. :)
But i'll let you judge anyway. :)
This is exactly the issue that the sha1sum solves: the files can be hosted anywhere, and the client will validate it ONLY if the sha1sum matches. This means that if the file size is different, the sha1sum is different (unless you find a collision, which with sha1sum is hard to do and keep a valid .love file.)
You'll notice the https://github.com/josefnpat/vapor/tree/master/dev/buildcache folder which is slowly preparing for repository mirrors. I will be very happy to host the first so to speak, but that relates to #75
seppi@penguinista:~/repos/vapor/dev/buildcache$ ./buildcache.sh
Checking cache first...
Aeternum Blammo IMAGE(CACHE)[OK] LOVE(CACHE)[OK]
Doctor Cat: The Game IMAGE(CACHE)[OK] LOVE(CACHE)[OK]
Giga Pudding: The Game IMAGE(CACHE)[OK] LOVE(CACHE)[OK]
Pocket Strife IMAGE(CACHE)[OK] LOVE(CACHE)[OK]
The Singularity is Here! IMAGE(CACHE)[OK] LOVE(CACHE)[OK]
Dun.Gen IMAGE(CACHE)[OK] LOVE(CACHE)[OK]
Mini Pirates! IMAGE(CACHE)[OK] LOVE(CACHE)[OK]
Sis, Help Me! IMAGE(CACHE)[OK] LOVE(CACHE)[OK]
XAPALUS IMAGE(CACHE)[OK] LOVE(CACHE)[OK]
Mari0 IMAGE(CACHE)[OK] LOVE(CACHE)[OK]
Ortho Robot IMAGE(CACHE)[OK] LOVE(CACHE)[OK]
Mr. Rescue IMAGE(CACHE)[OK] LOVE(CACHE)[OK]
Sienna IMAGE(CACHE)[OK] LOVE(CACHE)[OK]
Volcanox IMAGE(CACHE)[OK] LOVE(CACHE)[OK]
Wulcan IMAGE(CACHE)[OK] LOVE(CACHE)[OK]
ExoSlime IMAGE(CACHE)[OK] LOVE(CACHE)[OK]
X-Moon IMAGE(CACHE)[OK] LOVE(CACHE)[OK]
Moondar IMAGE(CACHE)[OK] LOVE(CACHE)[OK]
*Swoosh* Bubble-Fishing! IMAGE(CACHE)[OK] LOVE(CACHE)[OK]
Soundscape IMAGE(CACHE)[OK] LOVE(CACHE)[OK]
FOUR IMAGE(CACHE)[OK] LOVE(CACHE)[OK]
Tower Quest IMAGE(CACHE)[OK] LOVE(CACHE)[OK]
Metanet Hunter IMAGE(CACHE)[OK] LOVE(CACHE)[OK]
Rogue Fleet IMAGE(CACHE)[OK] LOVE(CACHE)[OK]
trAInsported IMAGE(CACHE)[OK] LOVE(CACHE)[OK]
Idiot: Puzzles IMAGE(CACHE)[OK] LOVE(CACHE)[OK]
Love Hotel IMAGE(CACHE)[OK] LOVE(CACHE)[OK]
Ouroboros IMAGE(CACHE)[OK] LOVE(CACHE)[OK]
Hawkthorne (Beta) IMAGE(CACHE)[OK] LOVE(CACHE)[OK]
WarpRun IMAGE(CACHE)[OK] LOVE(CACHE)[OK]
Snayke (Demo) IMAGE(CACHE)[OK] LOVE(CACHE)[OK]
Child of Winter IMAGE(CACHE)[OK] LOVE(CACHE)[OK]
Defense of Your Craft IMAGE(CACHE)[OK] LOVE(CACHE)[OK]
Desert Loot IMAGE(CACHE)[OK] LOVE(CACHE)[OK]
In Your Face City Trains IMAGE(CACHE)[OK] LOVE(CACHE)[OK]
Monkey See Monkey Do IMAGE(CACHE)[OK] LOVE(CACHE)[OK]
Matt and Chris IMAGE(CACHE)[OK] LOVE(CACHE)[OK]
Left Right Pong IMAGE(CACHE)[OK] LOVE(CACHE)[OK]
You Want The Money? IMAGE(CACHE)[OK] LOVE(CACHE)[OK]
Triad IMAGE(CACHE)[OK] LOVE(CACHE)[OK]
Feed My Boyfriend IMAGE(CACHE)[OK] LOVE(CACHE)[OK]
The Binding of Crate Box IMAGE(CACHE)[OK] LOVE(CACHE)[OK]
Snaik IMAGE(CACHE)[OK] LOVE(CACHE)[OK]
NetWars IMAGE(CACHE)[OK] LOVE(CACHE)[OK]
HOX IMAGE(CACHE)[OK] LOVE(CACHE)[OK]
UBO (Unknown Bouncing Objects) IMAGE(CACHE)[OK] LOVE(CACHE)[OK]
seppi@penguinista:~/repos/vapor/dev/buildcache$ ./buildcache.sh
Checking cache first...
Aeternum Blammo IMAGE(CACHE)[OK] LOVE(CACHE)[OK] 4985965B
^Cluajit-2.0.0-beta9: ./lib/hash.lua:380: interrupted!
stack traceback:
./lib/hash.lua:380: in function 'process'
./buildcache.lua:77: in main chunk
[C]: ?
Doctor Cat: The Game IMAGE(CACHE)[OK] LOVE(CACHE)
seppi@penguinista:~/repos/vapor/dev/buildcache$ du -b cache/Aeternum_Blammo-1375504351.love
4985965 cache/Aeternum_Blammo-1375504351.love
Lua matches the correct size of the file for *nix. I will push the file sizes into the games.json
soon
Oh, I didin't noticed that. Awesome. Go ahead, then. :+1:
Please see:
https://github.com/josefnpat/vapor/commit/fb00a7de5ff2b52540901238e4d90798eeea0bcb https://github.com/josefnpat/vapor/commit/b9a9c75c8385fa33405d793f03f6d1a9949def71 https://github.com/josefnpat/vapor/commit/b9c6763fe48034a591db158ab61783204b5816e2
This is, as always for major versions, backwards compatible :)
This is perfect.
Hi,
I think it would be nice to display the size of each game to be downloaded, in megabytes. I found that the following seems to be working. I am not used to LuaSocket, but I manage to get this to working well.
It returns the file size in bytes, if ok. Otherwise, in case some error occured, it returns -1. The thing is, as this spawns an http request, in cannot be done in batch for all games on startup, or it'll halt the whole app. But it can be streamed with coroutines, using the async framework you are actually using to download the *.love games, or the images.
Thoughts ?
Regards, Roland.