From aa1c92130273716e8c7318bfd0e13aaa1f3fe39d Mon Sep 17 00:00:00 2001 From: ed Date: Wed, 27 Aug 2025 19:17:36 +0000 Subject: [PATCH] support file-as-volume (#696); a volume can be a single file instead of a folder, but a misleading warning indicated otherwise --- README.md | 2 ++ copyparty/up2k.py | 6 ++++++ 2 files changed, 8 insertions(+) diff --git a/README.md b/README.md index c1a06d01..a0b71d3a 100644 --- a/README.md +++ b/README.md @@ -572,6 +572,8 @@ for example `-v /mnt::r -v /var/empty:web/certs:r` mounts the server folder `/mn the example config file right above this section may explain this better; the first volume `/` is mapped to `/srv` which means http://127.0.0.1:3923/music would try to read `/srv/music` on the server filesystem, but since there's another volume at `/music` mapped to `/mnt/music` then it'll go to `/mnt/music` instead +> ℹ️ this also works for single files, because files can also be volumes + ## dotfiles diff --git a/copyparty/up2k.py b/copyparty/up2k.py index 13c57160..1fc52333 100644 --- a/copyparty/up2k.py +++ b/copyparty/up2k.py @@ -926,6 +926,12 @@ class Up2k(object): with self.mutex, self.reg_mutex: # only need to protect register_vpath but all in one go feels right for vol in vols: + if bos.path.isfile(vol.realpath): + self.volstate[vol.vpath] = "online (just-a-file)" + t = "NOTE: volume [/%s] is a file, not a folder" + self.log(t % (vol.vpath,)) + continue + try: # mkdir gonna happen at snap anyways; bos.makedirs(vol.realpath, vf=vol.flags)