diff --git a/bin/partyfuse.py b/bin/partyfuse.py index 4b6ab90e..07317c72 100755 --- a/bin/partyfuse.py +++ b/bin/partyfuse.py @@ -626,7 +626,7 @@ class Gateway(object): "st_atime": ts, "st_mtime": ts, "st_ctime": ts, - "st_blocks": int((sz + 511) / 512), + "st_blocks": -int(-sz // 512), } def stat_file(self, ts, sz): @@ -638,7 +638,7 @@ class Gateway(object): "st_atime": ts, "st_mtime": ts, "st_ctime": ts, - "st_blocks": int((sz + 511) / 512), + "st_blocks": -int(-sz // 512), } diff --git a/bin/u2c.py b/bin/u2c.py index 1d9696bd..61a27340 100755 --- a/bin/u2c.py +++ b/bin/u2c.py @@ -398,7 +398,7 @@ class MTHash(object): self.csz = chunksz chunks = {} - nchunks = int(math.ceil(fsz / chunksz)) + nchunks = -int(-fsz // chunksz) for nch in range(nchunks): self.work_q.put(nch) @@ -725,7 +725,7 @@ def up2k_chunksize(filesize): stepsize = 512 * 1024 while True: for mul in [1, 2]: - nchunks = math.ceil(filesize * 1.0 / chunksize) + nchunks = -int(-filesize // chunksize) if nchunks <= 256 or (chunksize >= 32 * 1024 * 1024 and nchunks <= 4096): return chunksize diff --git a/copyparty/httpsrv.py b/copyparty/httpsrv.py index e56ccd52..20916745 100644 --- a/copyparty/httpsrv.py +++ b/copyparty/httpsrv.py @@ -318,7 +318,7 @@ class HttpSrv(object): self.srvs.append(sck) self.bound.add((ip, port)) - self.nclimax = math.ceil(self.args.nc * 1.0 / nlisteners) + self.nclimax = -int(-self.args.nc // nlisteners) Daemon( self.thr_listen, "httpsrv-n{}-listen-{}-{}".format(self.nid or "0", ip, port), diff --git a/copyparty/up2k.py b/copyparty/up2k.py index bf5036fe..3027b1dc 100644 --- a/copyparty/up2k.py +++ b/copyparty/up2k.py @@ -5704,7 +5704,7 @@ def up2k_chunksize(filesize: int) -> int: stepsize = 512 * 1024 while True: for mul in [1, 2]: - nchunks = math.ceil(filesize * 1.0 / chunksize) + nchunks = -int(-filesize // chunksize) if nchunks <= 256 or (chunksize >= 32 * 1024 * 1024 and nchunks <= 4096): return chunksize diff --git a/copyparty/util.py b/copyparty/util.py index 0045ec8a..1fd8fb25 100644 --- a/copyparty/util.py +++ b/copyparty/util.py @@ -1355,7 +1355,7 @@ class MTHash(object): self.csz = chunksz chunks: dict[int, tuple[str, int, int]] = {} - nchunks = int(math.ceil(fsz / chunksz)) + nchunks = -int(-fsz // chunksz) for nch in range(nchunks): self.work_q.put(nch) diff --git a/docs/chunksizes.py b/docs/chunksizes.py index 7b24d664..231f1e8d 100755 --- a/docs/chunksizes.py +++ b/docs/chunksizes.py @@ -26,7 +26,7 @@ def up2k_chunksize(filesize): stepsize = 512 * 1024 while True: for mul in [1, 2]: - nchunks = math.ceil(filesize * 1.0 / chunksize) + nchunks = -int(-filesize // chunksize) if nchunks <= 256 or (chunksize >= 32 * 1024 * 1024 and nchunks <= 4096): return chunksize