mar10 / pyftpsync

Synchronize directories using FTP(S), SFTP, or file system access.
https://pyftpsync.readthedocs.io
MIT License
117 stars 25 forks source link

Error if the local filesystem is read-only. #59

Closed LuckyResistor closed 3 years ago

LuckyResistor commented 3 years ago

If I try to use upload from a read-only file system, the command fails with an exception.

pyftpsync upload --delete --resolve local /mnt/read-only-mount ftps://example.com/
Traceback (most recent call last):
  File "xxx/venv/bin/pyftpsync", line 8, in <module>
    sys.exit(run())
  File "xxx/venv/lib/python3.8/site-packages/ftpsync/pyftpsync.py", line 242, in run
    s.run()
  File "xxx/venv/lib/python3.8/site-packages/ftpsync/synchronizers.py", line 1106, in run
    res = super(UploadSynchronizer, self).run()
  File "xxx/venv/lib/python3.8/site-packages/ftpsync/synchronizers.py", line 827, in run
    res = super(BiDirSynchronizer, self).run()
  File "xxx/venv/lib/python3.8/site-packages/ftpsync/synchronizers.py", line 213, in run
    res = self._sync_dir()
  File "xxx/venv/lib/python3.8/site-packages/ftpsync/synchronizers.py", line 571, in _sync_dir
    self.local.flush_meta()
  File "xxx/venv/lib/python3.8/site-packages/ftpsync/targets.py", line 404, in flush_meta
    self.cur_dir_meta.flush()
  File "xxx/venv/lib/python3.8/site-packages/ftpsync/metadata.py", line 223, in flush
    self.target.write_text(self.filename, s)
  File "xxx/venv/lib/python3.8/site-packages/ftpsync/targets.py", line 318, in write_text
    self.write_file(name, buf)
  File "xxx/venv/lib/python3.8/site-packages/ftpsync/targets.py", line 463, in write_file
    with open(os.path.join(self.cur_dir, name), "wb") as fp_dst:
OSError: [Errno 30] Read-only file system: '/mnt/read-only-mount/.pyftpsync-meta.json'
mar10 commented 3 years ago

There have been similar requests (#19 and #34), so you may give an upvote there. But realistically, given the low resources I can currently invest, I might not address this in the near future (PRs welcome).