pdemonaco / factorio-mod-updater

Python script to update mods on a dedicated factorio server
43 stars 14 forks source link

factorio-mod-updater doesn’t write the achive on the disk even if the rights on the folder are right #17

Open alarig opened 4 years ago

alarig commented 4 years ago

Hi,

factorio-mod-updater fails to update the mods here:

factorio@factorio ~ $ factorio-mod-updater --update -s /opt/factorio-0.18/config/server-settings.json -m /opt/factorio-0.18/mods --fact-path /opt/factorio-0.18/bin/x64/factorio
Factorio Release: 0.18

Retrieving metadata...........complete!

Mod                         Version Action      Result      Message
Traceback (most recent call last):
  File "/usr/lib/python-exec/python3.7/factorio-mod-updater", line 652, in <module>
    UPDATER.update()
  File "/usr/lib/python-exec/python3.7/factorio-mod-updater", line 472, in update
    self._download_latest_release(mod)
  File "/usr/lib/python-exec/python3.7/factorio-mod-updater", line 579, in _download_latest_release
    if _validate_hash(latest['sha1'], target):
  File "/usr/lib/python-exec/python3.7/factorio-mod-updater", line 39, in _validate_hash
    with open(target, 'rb') as target_fp:
FileNotFoundError: [Errno 2] No such file or directory: '/opt/factorio-0.18/mods/FARL_4.0.4.zip'

But I can write the file without changing the user:

factorio@factorio ~ $ touch /opt/factorio-0.18/mods/FARL_4.0.4.zip
factorio@factorio ~ $ rm /opt/factorio-0.18/mods/FARL_4.0.4.zip
factorio@factorio ~ $ 
pdemonaco commented 4 years ago

Hi @alarig

Couple quick questions:

Thanks!

alarig commented 4 years ago

Of course!

It seems that I don’t have any mod-settings.json, I have mod-settings.dat but it’s not a text file though:

factorio@factorio ~ $ find /opt/factorio-0.18/ -name mod-settings.json
factorio@factorio ~ $ find /opt/factorio-0.18/ -name 'mod-settings.*'
/opt/factorio-0.18/mods/mod-settings.dat
factorio@factorio ~ $ file /opt/factorio-0.18/mods/mod-settings.dat 
/opt/factorio-0.18/mods/mod-settings.dat: data

If it’s supposed to be generated by factorio, I run it like this: /opt/factorio-0.18/bin/x64/factorio --start-server-load-latest --server-settings config/server-settings.json --use-server-whitelist true --server-whitelist config/server-whitelist.json

Here is the content of my mods dir:

factorio@factorio ~ $ ls -la /opt/factorio-0.18/mods/
total 241652
drwxr-xr-x 2 factorio factorio      4096 Aug 29 13:55  .
drwxr-x--- 8 factorio factorio      4096 Aug 14 12:19  ..
-rw-r--r-- 1 factorio alarig     4352511 May 29 07:57  beautiful_bridge_railway_0.18.1.zip
-rw-r--r-- 1 factorio alarig    60906076 May 29 07:58  cargo-ships_0.0.54.zip
-rw-r--r-- 1 factorio alarig      130943 Jun 27 21:06  FNEI_0.3.4.zip
-rw-r--r-- 1 factorio alarig     3885180 Aug  9 18:27  HelicopterRevival_0.0.5.zip
-rw-r--r-- 1 factorio alarig   176395408 Jul 20 00:38  Krastorio2_0.9.99.zip
-rw-r--r-- 1 factorio factorio       860 Aug 14 12:19  mod-list.2020-08-17_2200.02.json
-rw-r--r-- 1 factorio factorio       738 Aug 18 00:00  mod-list.2020-08-18_2200.02.json
-rw-r--r-- 1 factorio factorio       738 Aug 19 00:00  mod-list.2020-08-19_2200.02.json
-rw-r--r-- 1 factorio factorio       738 Aug 20 00:00  mod-list.2020-08-20_2200.01.json
-rw-r--r-- 1 factorio factorio       738 Aug 21 00:00  mod-list.2020-08-21_2200.02.json
-rw-r--r-- 1 factorio factorio       738 Aug 22 00:00  mod-list.2020-08-22_2200.01.json
-rw-r--r-- 1 factorio factorio       738 Aug 23 00:00  mod-list.2020-08-23_2200.01.json
-rw-r--r-- 1 factorio factorio       738 Aug 24 00:00  mod-list.json
-rw-r--r-- 1 factorio factorio      3478 Aug 11 21:33  mod-settings.dat
-rw-r--r-- 1 factorio alarig       42450 Jun 27 17:31 'Orphan Finder_1.1.2.zip'
-rw-r--r-- 1 factorio alarig      817057 May 29 07:59  Realistic_Electric_Trains_0.4.4.zip
-rw-r--r-- 1 factorio alarig       39699 Jun 23 18:19 'Squeak Through_1.8.0.zip'
-rw-r--r-- 1 factorio alarig      752022 May 29 07:59  Warehousing_0.3.0.zip
-rw-r--r-- 1 factorio factorio     63037 Aug 17 10:04  YARM_0.8.102.zip

FARL has been removed by the script, but is enabled on the game (since I didn’t restated it since then).

Thanks!

pdemonaco commented 4 years ago

Oh, my mistake - it's mod-list.json. Permissions look fine on your directory so I think this is some other kind of bug. If you send me your mod-list.json file I should be able to reproduce the problem.

Thanks!

alarig commented 4 years ago

Sorry for the delay, I’m kind of busy :/ Here is the asked JSON:

{
  "mods": [
    {
      "enabled": true,
      "name": "FARL"
    },
    {
      "enabled": true,
      "name": "FNEI"
    },
    {
      "enabled": true,
      "name": "HelicopterRevival"
    },
    {
      "enabled": true,
      "name": "Krastorio2"
    },
    {
      "enabled": true,
      "name": "Orphan Finder"
    },
    {
      "enabled": true,
      "name": "Realistic_Electric_Trains"
    },
    {
      "enabled": true,
      "name": "Squeak Through"
    },
    {
      "enabled": true,
      "name": "Warehousing"
    },
    {
      "enabled": true,
      "name": "YARM"
    },
    {
      "enabled": true,
      "name": "beautiful_bridge_railway"
    },
    {
      "enabled": true,
      "name": "cargo-ships"
    }
  ]
}
pdemonaco commented 4 years ago

No worries - same here. I wasn't able produce the problem in my environment. Is it possible that you're out of disk space (or close to) in your /opt filesystem?

You can check via df -h /opt/factorio-0.18/mods

alarig commented 4 years ago

I thought about something like this too but I have some space left:

alarig@factorio ~ $ df -Th
Filesystem     Type      Size  Used Avail Use% Mounted on
/dev/root      ext4       47G  7.9G   37G  18% /
devtmpfs       devtmpfs   10M     0   10M   0% /dev
tmpfs          tmpfs     395M  424K  394M   1% /run
cgroup_root    tmpfs      10M     0   10M   0% /sys/fs/cgroup
shm            tmpfs     2.0G     0  2.0G   0% /dev/shm

I’m using an ebuild to install it, but maybe I forgot something.

Here is the list of the files:

alarig@factorio ~ $ equery files factorio-mod-updater
 * Searching for factorio-mod-updater ...
 * Contents of games-util/factorio-mod-updater-0.2.2:
/usr
/usr/bin
/usr/bin/factorio-mod-updater -> ../lib/python-exec/python-exec2
/usr/lib
/usr/lib/python-exec
/usr/lib/python-exec/python3.7
/usr/lib/python-exec/python3.7/factorio-mod-updater
/usr/share
/usr/share/doc
/usr/share/doc/factorio-mod-updater-0.2.2
/usr/share/doc/factorio-mod-updater-0.2.2/README.md.bz2

If it could help, this the python interpreter header:

Python 3.7.8 (default, Jul 22 2020, 23:12:26) 
[GCC 9.2.0] on linux
pdemonaco commented 3 years ago

Sorry for the delay - I totally forgot about this issue and my mail client decided Github notifications were spam...

Interesting. I actually have the script bundled in my ebuild for Factorio itself. I haven't updated the build since the 1.0 release though so there could be some new bugs.

I'm putting the script in the /opt/factorio/bin directory and I only call it via the mods_update function in the OpenRC init script which is also part of the ebuild.

I probably should have asked this earlier - is the Factorio process stopped when you run the update? It shouldn't prevent the creation of new files, but maybe this error is actually happening when it tries to delete the old version of the mod and Factorio has it open.

alarig commented 3 years ago

No problem ;)

I’m running it from a cron, while the server is started (I have two different ebuilds), it doesn’t seem that there is updates for my mods at the moment, so I will stop the server next time an update is needed and we’ll see.