Fixed API test case for restore.

pull/9335/head REL-9_10
Akshay Joshi 2025-11-10 13:26:42 +05:30
parent f251fdfdb1
commit 60c56b3285
1 changed files with 14 additions and 9 deletions

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