Skip to content

Commit

Permalink
When libsreg directory contains no files, it forces re-download
Browse files Browse the repository at this point in the history
by ignoring E-Tag.
  • Loading branch information
ateska committed Oct 15, 2024
1 parent 0fd7da7 commit 6da36c6
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions asab/library/providers/libsreg.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,9 +110,15 @@ async def _periodic_pull(self, event_name):
# Check for existing E-Tag
etag_fname = os.path.join(self.RootPath, "etag")
if os.path.exists(etag_fname):
with open(etag_fname, 'r') as f:
etag = f.read().strip()
headers['If-None-Match'] = etag

# Count number of files in self.RootPath recursively
file_count = sum([len(files) for _, _, files in os.walk(self.RootPath)])

# If less than 5 files, we ignore the E-Tag and re-download everything
if file_count > 5:
with open(etag_fname, 'r') as f:
etag = f.read().strip()
headers['If-None-Match'] = etag

# Prepare a list of URLs to try
# Randomize the order of the URLs (there might be more than one server to try)
Expand Down

0 comments on commit 6da36c6

Please sign in to comment.