Skip to content

Commit

Permalink
fix cookie_verf; allow specifying chunk size via env var
Browse files Browse the repository at this point in the history
  • Loading branch information
Wazzaps committed Oct 16, 2023
1 parent 4e4da9e commit 4d9336b
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions ampm/repo/nfs.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
from ampm.repo.local import LOCAL_REPO
from ampm.utils import _calc_dir_size, remove_atexit, LockFile

DEFAULT_CHUNK_SIZE = 1024 * 256
DEFAULT_CHUNK_SIZE = int(os.environ.get("AMPM_CHUNK_SIZE", str(1024 * 256)))
NFS_OP_TIMEOUT_SEC = 16


Expand Down Expand Up @@ -211,9 +211,11 @@ def list_dir(self, remote_path: str):
_validate_path(remote_path)
fh, _attrs = self._open(self._splitpath(remote_path))
cookie = 0
cookie_verf = '0'
while True:
readdir_res = self.nfs3.readdir(fh, cookie=cookie)
readdir_res = self.nfs3.readdir(fh, cookie=cookie, cookie_verf=cookie_verf)
if readdir_res["status"] == NFS3_OK:
cookie_verf = readdir_res["resok"]["cookieverf"]
entry = readdir_res["resok"]["reply"]["entries"]
while entry:
yield entry[0]['name']
Expand All @@ -230,11 +232,13 @@ def walk_files(self, remote_path: str, include_dirs: bool = False):
_validate_path(remote_path)
fh, _attrs = self._open(self._splitpath(remote_path))
cookie = 0
cookie_verf = '0'
while True:
readdir_res = self.nfs3.readdir(fh, cookie=cookie)
readdir_res = self.nfs3.readdir(fh, cookie=cookie, cookie_verf=cookie_verf)
if readdir_res["status"] == NFS3_OK:
if include_dirs:
yield remote_path
cookie_verf = readdir_res["resok"]["cookieverf"]
entry = readdir_res["resok"]["reply"]["entries"]
while entry:
if not entry[0]['name'].startswith(b'.'):
Expand Down

0 comments on commit 4d9336b

Please sign in to comment.