filter_file: make tempfile later (#48108)
* filter_file: make tempfile later * also add a `.` after the filename
This commit is contained in:
parent
d35202d83e
commit
a07e372770
@ -344,15 +344,17 @@ def groupid_to_group(x):
|
|||||||
regex = re.escape(regex)
|
regex = re.escape(regex)
|
||||||
regex_compiled = re.compile(regex)
|
regex_compiled = re.compile(regex)
|
||||||
for path in path_to_os_path(*filenames):
|
for path in path_to_os_path(*filenames):
|
||||||
fd, temp_path = tempfile.mkstemp(prefix=os.path.basename(path), dir=os.path.dirname(path))
|
|
||||||
os.close(fd)
|
|
||||||
|
|
||||||
if ignore_absent and not os.path.exists(path):
|
if ignore_absent and not os.path.exists(path):
|
||||||
tty.debug(f'FILTER FILE: file "{path}" not found. Skipping to next file.')
|
tty.debug(f'FILTER FILE: file "{path}" not found. Skipping to next file.')
|
||||||
continue
|
continue
|
||||||
else:
|
else:
|
||||||
tty.debug(f'FILTER FILE: {path} [replacing "{regex}"]')
|
tty.debug(f'FILTER FILE: {path} [replacing "{regex}"]')
|
||||||
|
|
||||||
|
fd, temp_path = tempfile.mkstemp(
|
||||||
|
prefix=f"{os.path.basename(path)}.", dir=os.path.dirname(path)
|
||||||
|
)
|
||||||
|
os.close(fd)
|
||||||
|
|
||||||
shutil.copy(path, temp_path)
|
shutil.copy(path, temp_path)
|
||||||
errored = False
|
errored = False
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user