vnrecode: fix duplicates check for case insensitive fs
This commit is contained in:
parent
90a6b4e0c1
commit
0b43756ef5
2 changed files with 7 additions and 5 deletions
|
@ -42,7 +42,7 @@ class Application:
|
||||||
with ThreadPoolExecutor(max_workers=self.params.workers) as executor:
|
with ThreadPoolExecutor(max_workers=self.params.workers) as executor:
|
||||||
futures = [
|
futures = [
|
||||||
executor.submit(self.compress, folder, file, source, output)
|
executor.submit(self.compress, folder, file, source, output)
|
||||||
for file in files if os.path.isfile(f'{folder}/{file}')
|
for file in files if os.path.isfile(os.path.join(folder, file))
|
||||||
]
|
]
|
||||||
for future in as_completed(futures):
|
for future in as_completed(futures):
|
||||||
future.result()
|
future.result()
|
||||||
|
|
|
@ -4,6 +4,9 @@ import sys
|
||||||
import os
|
import os
|
||||||
import re
|
import re
|
||||||
|
|
||||||
|
import fnmatch
|
||||||
|
|
||||||
|
|
||||||
class Utils:
|
class Utils:
|
||||||
|
|
||||||
def __init__(self, params, printer):
|
def __init__(self, params, printer):
|
||||||
|
@ -64,12 +67,11 @@ class Utils:
|
||||||
self.printer.info(f"File {filename} copied to compressed folder.")
|
self.printer.info(f"File {filename} copied to compressed folder.")
|
||||||
|
|
||||||
def check_duplicates(self, source: str, output: str, filename: str) -> str:
|
def check_duplicates(self, source: str, output: str, filename: str) -> str:
|
||||||
files = glob(os.path.join(source, os.path.splitext(filename)[0])+".*")
|
re_pattern = re.compile(os.path.splitext(filename)[0]+r".[a-zA-Z0-9]+$", re.IGNORECASE)
|
||||||
re_pattern = re.compile(os.path.join(source, os.path.splitext(filename)[0])+r".[a-zA-Z0-9]+$")
|
duplicates = [name for name in os.listdir(source) if re_pattern.match(name)]
|
||||||
duplicates = [f for f in files if re_pattern.match(f)]
|
|
||||||
|
|
||||||
if len(duplicates) > 1:
|
if len(duplicates) > 1:
|
||||||
if filename not in self.duplicates:
|
if filename.lower() not in (duplicate.lower() for duplicate in self.duplicates):
|
||||||
self.duplicates.append(filename)
|
self.duplicates.append(filename)
|
||||||
new_name = os.path.splitext(filename)[0] + "(vncopy)" + os.path.splitext(filename)[1]
|
new_name = os.path.splitext(filename)[0] + "(vncopy)" + os.path.splitext(filename)[1]
|
||||||
return os.path.join(output, new_name)
|
return os.path.join(output, new_name)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue