Fixed API test case for restore.

This commit is contained in:
Akshay Joshi committed 2025-11-10 13:26:42 +05:30
1 parent f251fdfdb1
commit 60c56b3285
1 file changed
+14 -9
+14 -9
View File
@@ -384,17 +384,22 @@ def has_meta_commands(path, chunk_size=8 * 1024 * 1024):
# optional spaces, then backslash
pattern = re.compile(br'(^|\n)[ \t]*\\')
with open(path, "rb") as f:
prev_tail = b""
while chunk := f.read(chunk_size):
data = prev_tail + chunk
try:
with open(path, "rb") as f:
prev_tail = b""
while chunk := f.read(chunk_size):
data = prev_tail + chunk
# Search for pattern
if pattern.search(data):
return True
# Search for pattern
if pattern.search(data):
return True
# Keep a small tail to preserve line boundary context
prev_tail = data[-10:] # keep last few bytes
# Keep a small tail to preserve line boundary context
prev_tail = data[-10:] # keep last few bytes
except FileNotFoundError:
current_app.logger.error("File not found.")
except PermissionError:
current_app.logger.error("Insufficient permissions to access.")
return False