copyparty 1.18.3__py3-none-any.whl → 1.18.4__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
copyparty/__main__.py CHANGED
@@ -1542,6 +1542,7 @@ def add_ui(ap, retry):
1542
1542
  ap2.add_argument("--nsort", action="store_true", help="default-enable natural sort of filenames with leading numbers (volflag=nsort)")
1543
1543
  ap2.add_argument("--hsortn", metavar="N", type=int, default=2, help="number of sorting rules to include in media URLs by default (volflag=hsortn)")
1544
1544
  ap2.add_argument("--see-dots", action="store_true", help="default-enable seeing dotfiles; only takes effect if user has the necessary permissions")
1545
+ ap2.add_argument("--qdel", metavar="LVL", type=int, default=2, help="number of confirmations to show when deleting files (2/1/0)")
1545
1546
  ap2.add_argument("--unlist", metavar="REGEX", type=u, default="", help="don't show files matching \033[33mREGEX\033[0m in file list. Purely cosmetic! Does not affect API calls, just the browser. Example: [\033[32m\\.(js|css)$\033[0m] (volflag=unlist)")
1546
1547
  ap2.add_argument("--favico", metavar="TXT", type=u, default="c 000 none" if retry else "🎉 000 none", help="\033[33mfavicon-text\033[0m [ \033[33mforeground\033[0m [ \033[33mbackground\033[0m ] ], set blank to disable")
1547
1548
  ap2.add_argument("--ext-th", metavar="E=VP", type=u, action="append", help="use thumbnail-image \033[33mVP\033[0m for file-extension \033[33mE\033[0m, example: [\033[32mexe=/.res/exe.png\033[0m] (volflag=ext_th)")
copyparty/__version__.py CHANGED
@@ -1,8 +1,8 @@
1
1
  # coding: utf-8
2
2
 
3
- VERSION = (1, 18, 3)
3
+ VERSION = (1, 18, 4)
4
4
  CODENAME = "logtail"
5
- BUILD_DT = (2025, 7, 21)
5
+ BUILD_DT = (2025, 7, 25)
6
6
 
7
7
  S_VERSION = ".".join(map(str, VERSION))
8
8
  S_BUILD_DT = "{0:04d}-{1:02d}-{2:02d}".format(*BUILD_DT)
copyparty/authsrv.py CHANGED
@@ -379,20 +379,20 @@ class VFS(object):
379
379
  self.adot = {}
380
380
  self.js_ls = {}
381
381
  self.js_htm = ""
382
+ self.all_vols = {} # flattened recursive
383
+ self.all_nodes = {} # also jumpvols/shares
382
384
 
383
385
  if realpath:
384
386
  rp = realpath + ("" if realpath.endswith(os.sep) else os.sep)
385
387
  vp = vpath + ("/" if vpath else "")
386
388
  self.histpath = os.path.join(realpath, ".hist") # db / thumbcache
387
389
  self.dbpath = self.histpath
388
- self.all_vols = {vpath: self} # flattened recursive
389
- self.all_nodes = {vpath: self} # also jumpvols/shares
390
+ self.all_vols[vpath] = self
391
+ self.all_nodes[vpath] = self
390
392
  self.all_aps = [(rp, [self])]
391
393
  self.all_vps = [(vp, self)]
392
394
  else:
393
395
  self.histpath = self.dbpath = ""
394
- self.all_vols = {}
395
- self.all_nodes = {}
396
396
  self.all_aps = []
397
397
  self.all_vps = []
398
398
 
@@ -861,6 +861,53 @@ class VFS(object):
861
861
 
862
862
  return self
863
863
 
864
+ def check_landmarks(self) :
865
+ if self.dbv:
866
+ return True
867
+
868
+ vps = self.flags.get("landmark") or []
869
+ if not vps:
870
+ return True
871
+
872
+ failed = ""
873
+ for vp in vps:
874
+ if "^=" in vp:
875
+ vp, zs = vp.split("^=", 1)
876
+ expect = zs.encode("utf-8")
877
+ else:
878
+ expect = b""
879
+
880
+ if self.log:
881
+ t = "checking [/%s] landmark [%s]"
882
+ self.log("vfs", t % (self.vpath, vp), 6)
883
+
884
+ ap = "?"
885
+ try:
886
+ ap = self.canonical(vp)
887
+ with open(ap, "rb") as f:
888
+ buf = f.read(4096)
889
+ if not buf.startswith(expect):
890
+ t = "file [%s] does not start with the expected bytes %s"
891
+ failed = t % (ap, expect)
892
+ break
893
+ except Exception as ex:
894
+ t = "%r while trying to read [%s] => [%s]"
895
+ failed = t % (ex, vp, ap)
896
+ break
897
+
898
+ if not failed:
899
+ return True
900
+
901
+ if self.log:
902
+ t = "WARNING: landmark verification failed; %s; will now disable up2k database for volume [/%s]"
903
+ self.log("vfs", t % (failed, self.vpath), 3)
904
+
905
+ for rm in "e2d e2t e2v".split():
906
+ self.flags = {k: v for k, v in self.flags.items() if not k.startswith(rm)}
907
+ self.flags["d2d"] = True
908
+ self.flags["d2t"] = True
909
+ return False
910
+
864
911
 
865
912
  if WINDOWS:
866
913
  re_vol = re.compile(r"^([a-zA-Z]:[\\/][^:]*|[^:]*):([^:]*):(.*)$")
@@ -1493,7 +1540,7 @@ class AuthSrv(object):
1493
1540
  flags[name] = True
1494
1541
  return
1495
1542
 
1496
- zs = "ext_th mtp on403 on404 xbu xau xiu xbc xac xbr xar xbd xad xm xban"
1543
+ zs = "ext_th landmark mtp on403 on404 xbu xau xiu xbc xac xbr xar xbd xad xm xban"
1497
1544
  if name not in zs.split():
1498
1545
  if value is True:
1499
1546
  t = "└─add volflag [{}] = {} ({})"
@@ -2228,6 +2275,8 @@ class AuthSrv(object):
2228
2275
  t = "WARNING: volume [/%s]: invalid value specified for ext-th: %s"
2229
2276
  self.log(t % (vol.vpath, etv), 3)
2230
2277
 
2278
+ vol.check_landmarks()
2279
+
2231
2280
  # d2d drops all database features for a volume
2232
2281
  for grp, rm in [["d2d", "e2d"], ["d2t", "e2t"], ["d2d", "e2v"]]:
2233
2282
  if not vol.flags.get(grp, False):
@@ -2661,6 +2710,7 @@ class AuthSrv(object):
2661
2710
  "def_hcols": list(vf.get("mth") or []),
2662
2711
  "unlist0": vf.get("unlist") or "",
2663
2712
  "see_dots": self.args.see_dots,
2713
+ "dqdel": self.args.qdel,
2664
2714
  "dgrid": "grid" in vf,
2665
2715
  "dgsel": "gsel" in vf,
2666
2716
  "dnsort": "nsort" in vf,
copyparty/cfg.py CHANGED
@@ -222,6 +222,7 @@ flagcats = {
222
222
  "d2d": "disables all database stuff, overrides -e2*",
223
223
  "hist=/tmp/cdb": "puts thumbnails and indexes at that location",
224
224
  "dbpath=/tmp/cdb": "puts indexes at that location",
225
+ "landmark=foo": "disable db if file foo doesn't exist",
225
226
  "scan=60": "scan for new files every 60sec, same as --re-maxage",
226
227
  "nohash=\\.iso$": "skips hashing file contents if path matches *.iso",
227
228
  "noidx=\\.iso$": "fully ignores the contents at paths matching *.iso",
copyparty/httpcli.py CHANGED
@@ -5549,7 +5549,7 @@ class HttpCli(object):
5549
5549
  db.commit()
5550
5550
  db.close()
5551
5551
 
5552
- self.conn.hsrv.broker.ask("reload", False, False).get()
5552
+ self.conn.hsrv.broker.ask("reload", False, True).get()
5553
5553
 
5554
5554
  self.redirect("", "?idp")
5555
5555
  return True
@@ -5633,7 +5633,7 @@ class HttpCli(object):
5633
5633
 
5634
5634
  cur.connection.commit()
5635
5635
  if reload:
5636
- self.conn.hsrv.broker.ask("reload", False, False).get()
5636
+ self.conn.hsrv.broker.ask("reload", False, True).get()
5637
5637
  self.conn.hsrv.broker.ask("up2k.wake_rescanner").get()
5638
5638
 
5639
5639
  self.redirect("", "?shares")
@@ -5725,7 +5725,7 @@ class HttpCli(object):
5725
5725
  cur.execute(q, (skey, fn))
5726
5726
 
5727
5727
  cur.connection.commit()
5728
- self.conn.hsrv.broker.ask("reload", False, False).get()
5728
+ self.conn.hsrv.broker.ask("reload", False, True).get()
5729
5729
  self.conn.hsrv.broker.ask("up2k.wake_rescanner").get()
5730
5730
 
5731
5731
  fn = quotep(fns[0]) if len(fns) == 1 else ""
copyparty/up2k.py CHANGED
@@ -1371,6 +1371,10 @@ class Up2k(object):
1371
1371
  t = "volume /%s at [%s] is empty; will not be indexed as this could be due to an offline filesystem"
1372
1372
  self.log(t % (vol.vpath, rtop), 6)
1373
1373
  return True, False
1374
+ if not vol.check_landmarks():
1375
+ t = "volume /%s at [%s] will not be indexed due to bad landmarks"
1376
+ self.log(t % (vol.vpath, rtop), 6)
1377
+ return True, False
1374
1378
 
1375
1379
  n_add, _, _ = self._build_dir(
1376
1380
  db,
copyparty/util.py CHANGED
@@ -1889,7 +1889,7 @@ def rand_name(fdir , fn , rnd ) :
1889
1889
  return fn
1890
1890
 
1891
1891
 
1892
- def gen_filekey(alg , salt , fspath , fsize , inode ) :
1892
+ def _gen_filekey(alg , salt , fspath , fsize , inode ) :
1893
1893
  if alg == 1:
1894
1894
  zs = "%s %s %s %s" % (salt, fspath, fsize, inode)
1895
1895
  else:
@@ -1899,6 +1899,13 @@ def gen_filekey(alg , salt , fspath , fsize , inode ) :
1899
1899
  return ub64enc(hashlib.sha512(zb).digest()).decode("ascii")
1900
1900
 
1901
1901
 
1902
+ def _gen_filekey_w(alg , salt , fspath , fsize , inode ) :
1903
+ return _gen_filekey(alg, salt, fspath.replace("/", "\\"), fsize, inode)
1904
+
1905
+
1906
+ gen_filekey = _gen_filekey_w if ANYWIN else _gen_filekey
1907
+
1908
+
1902
1909
  def gen_filekey_dbg(
1903
1910
  alg ,
1904
1911
  salt ,
Binary file
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: copyparty
3
- Version: 1.18.3
3
+ Version: 1.18.4
4
4
  Summary: Portable file server with accelerated resumable uploads, deduplication, WebDAV, FTP, zeroconf, media indexer, video thumbnails, audio transcoding, and write-only folders
5
5
  Author-email: ed <copyparty@ocv.me>
6
6
  License: MIT
@@ -1663,7 +1663,7 @@ config file example:
1663
1663
  w: * # anyone can upload here
1664
1664
  rw: ed # only user "ed" can read-write
1665
1665
  flags:
1666
- e2ds: # filesystem indexing is required for many of these:
1666
+ e2ds # filesystem indexing is required for many of these:
1667
1667
  sz: 1k-3m # accept upload only if filesize in this range
1668
1668
  df: 4g # free disk space cannot go lower than this
1669
1669
  vmaxb: 1g # volume can never exceed 1 GiB
@@ -1720,6 +1720,8 @@ this can instead be kept in a single place using the `--hist` argument, or the `
1720
1720
 
1721
1721
  by default, the per-volume `up2k.db` sqlite3-database for `-e2d` and `-e2t` is stored next to the thumbnails according to the `--hist` option, but the global-option `--dbpath` and/or volflag `dbpath` can be used to put the database somewhere else
1722
1722
 
1723
+ if your storage backend is unreliable (NFS or bad HDDs), you can specify one or more "landmarks" to look for before doing anything database-related. A landmark is a file which is always expected to exist inside the volume. This avoids spurious filesystem rescans in the event of an outage. One line per landmark (see example below)
1724
+
1723
1725
  note:
1724
1726
  * putting the hist-folders on an SSD is strongly recommended for performance
1725
1727
  * markdown edits are always stored in a local `.hist` subdirectory
@@ -1737,6 +1739,8 @@ config file example:
1737
1739
  flags:
1738
1740
  hist: - # restore the default (/mnt/nas/pics/.hist/)
1739
1741
  hist: /mnt/nas/cache/pics/ # can be absolute path
1742
+ landmark: me.jpg # /mnt/nas/pics/me.jpg must be readable to enable db
1743
+ landmark: info/a.txt^=ok # and this textfile must start with "ok"
1740
1744
  ```
1741
1745
 
1742
1746
 
@@ -1,17 +1,17 @@
1
1
  copyparty/__init__.py,sha256=4aJw_Mt3eSNMV8sJ95Nh4ris-tBUYhCOV094Rnxa5Xo,2651
2
- copyparty/__main__.py,sha256=xfjyeCayxt3syWT1Iw6DDitRuQkrUcJvFUaEoWcIfMU,125889
3
- copyparty/__version__.py,sha256=D7P8wrGVX6EhXwfZYGNDWFK3D95DiMYHg7ohrpDSGMM,249
4
- copyparty/authsrv.py,sha256=TF6T254t2ZdcB_1nAq5xXQBjG5SKUtzIeN3RBhmzCtc,118943
2
+ copyparty/__main__.py,sha256=rfSaVAHy9NpF6U-dWu4NS6zab96v7DLnG95M7WRXyxo,126024
3
+ copyparty/__version__.py,sha256=VYBE-faUq6KuT0awfdhYnaqRvlnX2Tni0a63zOMGx_A,249
4
+ copyparty/authsrv.py,sha256=PDX6-ob-vqpKE8XkMCEph662EE4Mp8IKbtIEZUKk5IM,120514
5
5
  copyparty/broker_mp.py,sha256=QdOXXvV2Xn6J0CysEqyY3GZbqxQMyWnTpnba-a5lMc0,4987
6
6
  copyparty/broker_mpw.py,sha256=PpSS4SK3pItlpfD8OwVr3QmJEPKlUgaf2nuMOozixgU,3347
7
7
  copyparty/broker_thr.py,sha256=fjoYtpSscUA7-nMl4r1n2R7UK3J9lrvLS3rUZ-iJzKQ,1721
8
8
  copyparty/broker_util.py,sha256=76mfnFOpX1gUUvtjm8UQI7jpTIaVINX10QonM-B7ggc,1680
9
9
  copyparty/cert.py,sha256=pSSeVYticrDsnsrdRtfpUQN-8WRObsqrYtSRroXmgxo,7992
10
- copyparty/cfg.py,sha256=3rMq1XSGnzu5-_YU4DsDc9G2hMOv6VLPveF2mC3_CU8,15359
10
+ copyparty/cfg.py,sha256=O2jhYbt7WV9X80_Av1f7r4u1JVi7U5Z_cLgSGhpipLg,15423
11
11
  copyparty/dxml.py,sha256=vu5uZQtwvwoqnFHbULs2Zh_y2DETu0T-ENpMZ1i2CV4,2505
12
12
  copyparty/fsutil.py,sha256=NC_CJC4TDag399vVDH9_uQfdfpTMwRFLNxERSWhlVvs,4594
13
13
  copyparty/ftpd.py,sha256=xDDWixo5O2HT8wlexXQ0QRazU_fYERIJ4yF0mtu9wD0,18141
14
- copyparty/httpcli.py,sha256=lB7CvrqyWMkXAV39oJtPof5PzDRCg7nNh7cwOoVfgO4,230547
14
+ copyparty/httpcli.py,sha256=ZNwaI4DVM6ljDz5ALRVuk07qG19i66_CLm9h6eARTSA,230544
15
15
  copyparty/httpconn.py,sha256=IA9fdCjigawZ4kWhgvVN3nSiy5pb3W2qaE6rFqUYdq0,6943
16
16
  copyparty/httpsrv.py,sha256=x6dl6ZjpwYREbm-eJZYnwdkhDeCA58hw_iwUMCD1Wz8,18819
17
17
  copyparty/ico.py,sha256=-7QjF_jIxnPo4Vr0oUPksQ_U_Ef0HRsSPm3s71idOz8,3879
@@ -31,8 +31,8 @@ copyparty/tftpd.py,sha256=sNBMqazIB37t3jwhv_F1tr0lHFsiRX-nCsICM8nbkvc,14170
31
31
  copyparty/th_cli.py,sha256=IEX5tCb0gw9Z2aRIDL9bwdvJ6g5jhWZ8OEAAz16_xN4,5426
32
32
  copyparty/th_srv.py,sha256=INLaV1_NH1VKtBx9XaqyJbZNAj2ZhfcQwz0_5Y5fyiY,32744
33
33
  copyparty/u2idx.py,sha256=4Y5OOPyVkc-pS0z6e3p4StXAMnjHobSOMmMsvNUTD34,13674
34
- copyparty/up2k.py,sha256=KINADhvYxtCG6NEC2qytdBCsjqvOiaVR5tc6nmvlaho,178731
35
- copyparty/util.py,sha256=9juRzN_pfH7P1eZK9Tv5ZZzBVCf8ct1La1s9lUXsRSg,104193
34
+ copyparty/up2k.py,sha256=S-SPTzLqxFvgSkFsWHqJwgUeT7QguLZgdZMQIh5eWiU,178957
35
+ copyparty/util.py,sha256=p4Z2JHjIKWo-x5RS1kQl5qBG5T_E1FUV2pRfukAdyzA,104391
36
36
  copyparty/bos/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
37
37
  copyparty/bos/bos.py,sha256=ZwpTla_mFpoN_BbGn9h0dEn7wpZ607QJ7uYyxWJMcmw,1953
38
38
  copyparty/bos/path.py,sha256=yEjCq2ki9CvxA5sCT8pS0keEXwugs0ZeUyUhdBziOCI,777
@@ -57,7 +57,7 @@ copyparty/stolen/ifaddr/_win32.py,sha256=EE-QyoBgeB7lYQ6z62VjXNaRozaYfCkaJBHGNA8
57
57
  copyparty/web/baguettebox.js.gz,sha256=MxRofvhXjmUN7RtXtC17_9AlROVNUT-66WwJ_pHLY9c,8258
58
58
  copyparty/web/browser.css.gz,sha256=29D3F4uB-VMd6uJo-SxWAwLfn08jcETYZm0SOJFJLAE,11847
59
59
  copyparty/web/browser.html,sha256=auvhLVE_t0aIN0q-nk0zOWFqITgDhroMAAviBNLoFfc,4788
60
- copyparty/web/browser.js.gz,sha256=PuTSoalzqWJigJXmDkkgaiGR-n5ieR47SU4lOvOkLZk,96513
60
+ copyparty/web/browser.js.gz,sha256=EZ58H7mtO6VEjeNxU5ZOlbelSRTuc_-JAmAGd3S11aY,96694
61
61
  copyparty/web/browser2.html,sha256=NRUZ08GH-e2YcGXcoz0UjYg6JIVF42u4IMX4HHwWTmg,1587
62
62
  copyparty/web/cf.html,sha256=lJThtNFNAQT1ClCHHlivAkDGE0LutedwopXD62Z8Nys,589
63
63
  copyparty/web/dbg-audio.js.gz,sha256=Ma-KZtK8LnmiwNvNKFKXMPYl_Nn_3U7GsJ6-DRWC2HE,688
@@ -110,9 +110,9 @@ copyparty/web/deps/prismd.css.gz,sha256=ObUlksQVr-OuYlTz-I4B23TeBg2QDVVGRnWBz8cV
110
110
  copyparty/web/deps/scp.woff2,sha256=w99BDU5i8MukkMEL-iW0YO9H4vFFZSPWxbkH70ytaAg,8612
111
111
  copyparty/web/deps/sha512.ac.js.gz,sha256=lFZaCLumgWxrvEuDr4bqdKHsqjX82AbVAb7_F45Yk88,7033
112
112
  copyparty/web/deps/sha512.hw.js.gz,sha256=UAed2_ocklZCnIzcSYz2h4P1ycztlCLj-ewsRTud2lU,7939
113
- copyparty-1.18.3.dist-info/licenses/LICENSE,sha256=gOr4h33pCsBEg9uIy9AYmb7qlocL4V9t2uPJS5wllr0,1072
114
- copyparty-1.18.3.dist-info/METADATA,sha256=IwBSD6NubWRSBqPVhBc5i8L_1PLB_kwzvoz3SMVlUyo,165941
115
- copyparty-1.18.3.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
116
- copyparty-1.18.3.dist-info/entry_points.txt,sha256=4zw6a3rqASywQomiYLObjjlxybaI65LYYOTJwgKz7b0,128
117
- copyparty-1.18.3.dist-info/top_level.txt,sha256=LnYUPsDyk-8kFgM6YJLG4h820DQekn81cObKSu9g-sI,10
118
- copyparty-1.18.3.dist-info/RECORD,,
113
+ copyparty-1.18.4.dist-info/licenses/LICENSE,sha256=gOr4h33pCsBEg9uIy9AYmb7qlocL4V9t2uPJS5wllr0,1072
114
+ copyparty-1.18.4.dist-info/METADATA,sha256=4D8UUVWS75gzR3fW8ngJNPa_TNcGz8Dmci1CF_OHzq8,166420
115
+ copyparty-1.18.4.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
116
+ copyparty-1.18.4.dist-info/entry_points.txt,sha256=4zw6a3rqASywQomiYLObjjlxybaI65LYYOTJwgKz7b0,128
117
+ copyparty-1.18.4.dist-info/top_level.txt,sha256=LnYUPsDyk-8kFgM6YJLG4h820DQekn81cObKSu9g-sI,10
118
+ copyparty-1.18.4.dist-info/RECORD,,