Skip to content

Commit c2eb7c5

Browse files
authored
UI updates,NEW: limit folder depth
- Added new file type selection (merged custom and predefined lists) - Added new folder depth limit filter - System files and reverse search are now a checkbox - They don't have upfront labels anymore - Hiding Revere results when None is sorting method - Predefined and custom file tpe are now in the same spot and can be switched - Fixed bug where cache wouldn't get deleted or would always get deleted on launch - Caches are now store in fort [path.replace(os.sep, "-")]$[search_depth].FF_Cache - There is now a default filter list, resetting just imports it - Optimised spacing in workflows and REAMDE.md - Replaced '' with "" - Minimal code style optimisation with hash calculation
1 parent 8266301 commit c2eb7c5

10 files changed

+520
-399
lines changed

FF_Additional_UI.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
BOLD_QT_FONT = QFont(FF_Files.DEFAULT_FONT, FF_Files.DEFAULT_FONT_SIZE)
3535
BOLD_QT_FONT.setBold(True)
3636

37+
3738
# Used for entering the directory
3839
class DirectoryEntry(QLineEdit):
3940
def __init__(self, parent):

FF_Compare.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -246,11 +246,12 @@ def show_time_stats():
246246
logging.debug("Displaying time stats.")
247247

248248
# Getting the creation time of the cache file which is stored separately
249-
with open(FF_Files.path_to_cache_file(path_of_first_search, True)) as time_file1:
249+
with open(FF_Files.get_metadata_file_from_cache_file(cache_file)) as time_file1:
250250
# Load time
251251
search1_created_time = ctime(load(time_file1)["c_time"])
252252
# Getting the creation time of the cache file which is stored separately
253-
with open(FF_Files.path_to_cache_file(compared_searches.path_of_second_search[0], True)) as time_file2:
253+
with open(FF_Files.path_to_cache_file(
254+
compared_searches.path_of_second_search[0], -1, metadata=True)) as time_file2:
254255
search2_created_time = ctime(load(time_file2)["c_time"])
255256

256257
# Displaying infobox with time info

FF_Duplicated.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -744,8 +744,6 @@ def __init__(self, criteria: dict, matched_list, signals):
744744
# Updating hash
745745
computing_hash.update(data)
746746

747-
# Getting hash in hex form
748-
file_hash = computing_hash.hexdigest()
749747
except OSError:
750748
continue
751749
else:
@@ -776,8 +774,8 @@ def __init__(self, criteria: dict, matched_list, signals):
776774

777775
except OSError:
778776
continue
779-
# Getting hash in hex form
780-
file_hash = computing_hash.hexdigest()
777+
# Getting hash in hex form
778+
file_hash = computing_hash.hexdigest()
781779

782780
# If everything ran successful
783781
# If hash doesn't already exist
@@ -831,4 +829,4 @@ def sort_size(list_file_size, file_size):
831829
return size_difference * -1
832830

833831
else:
834-
return size_difference
832+
return size_difference

FF_Files.py

Lines changed: 34 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,16 @@
1616
from time import time
1717
import hashlib
1818

19+
from PySide6.QtCore import QDate, Qt
20+
1921
# Versions
20-
VERSION: str = "12-mar-2025"
21-
VERSION_SHORT: str = "1.2.1"
22+
VERSION: str = "25-apr-2025"
23+
VERSION_SHORT: str = "2.0"
2224
# Versions of file formats
23-
FF_FILTER_VERSION = 1
25+
FF_FILTER_VERSION = 2
2426
FF_SEARCH_VERSION = 2
2527
FF_SETTINGS_VERSION = 1
26-
FF_CACHE_VERSION = 2
28+
FF_CACHE_VERSION = 3
2729

2830
# Defining folder variables and font sizes
2931
USER_FOLDER = os.path.expanduser("~")
@@ -106,6 +108,19 @@
106108
"display_menu_bar_icon": True,
107109
"double_click_action": "View file in Finder/File Explorer"}
108110

111+
DEFAULT_FILTER = {"VERSION": FF_FILTER_VERSION,
112+
"name": "", "name_contains": "",
113+
"file_types": FILE_FORMATS.keys(),
114+
"file_extension": "", "file_type_mode": "predefined",
115+
"directory": USER_FOLDER,
116+
"dates": {"m_date_from": "2000-01-01", "c_date_from": "2000-01-01",
117+
"m_date_to": QDate.currentDate().toString(Qt.DateFormat.ISODate),
118+
"c_date_to": QDate.currentDate().toString(Qt.DateFormat.ISODate)},
119+
"size": {"min": "", "max": ""}, "size_unit": {"min": "No Limit", "max": "No Limit"},
120+
"folder_depth": "Unlimited", "folder_depth_custom": 0,
121+
"file_contains": "", "hidden_files": False,
122+
"files_folders": 0, "sorting": 0, "reverse_sorting": False}
123+
109124
# Color schemes
110125
RED_LIGHT_THEME_COLOR = "#b1100c"
111126
RED_DARK_THEME_COLOR = "#f27171"
@@ -125,14 +140,15 @@ def remove_cache():
125140

126141

127142
# Convert a file path to the corresponding cache file or metadata
128-
def path_to_cache_file(path, metadata=False):
143+
def path_to_cache_file(path, depth, metadata=False):
144+
# A -1 for the depth means unlimited depth
129145
if not metadata:
130-
return os.path.join(CACHED_SEARCHES_FOLDER, path.replace(os.sep, "-") + ".FFCache")
146+
return os.path.join(CACHED_SEARCHES_FOLDER, path.replace(os.sep, "-") + f"${depth}.FFCache")
131147
# If instead ask for metadata
132148
elif metadata:
133-
return os.path.join(CACHE_METADATA_FOLDER, path.replace(os.sep, "-") + ".FFCache")
149+
return os.path.join(CACHE_METADATA_FOLDER, path.replace(os.sep, "-") + f"${depth}.FFCache")
134150
else:
135-
logging.fatal("Wrong arguments used with the convert_path_to_cache_file() function in FF_Files.py")
151+
return logging.fatal("Wrong arguments used with the convert_path_to_cache_file() function in FF_Files.py")
136152

137153

138154
# Takes a path to a cache file and returns the path to the metadata file
@@ -172,7 +188,7 @@ def cache_test(is_launching):
172188
else:
173189
logging.debug("Skipping deleting...")
174190

175-
if cache_settings.lower() in ("after a Week", "after a Day", "after two hours"):
191+
if cache_settings.lower() in ("after a week", "after a day", "after two hours"):
176192
# Looping through every file in CACHED_SEARCHES_FOLDER and getting separately stored creation tie
177193
# Iterating through all files in the cache folder
178194
for file in os.listdir(CACHED_SEARCHES_FOLDER):
@@ -204,7 +220,10 @@ def cache_test(is_launching):
204220

205221
# Function to get the File Size of a directory
206222
def get_file_size(input_file: str) -> int:
207-
if os.path.isdir(input_file):
223+
if os.path.islink(input_file):
224+
# Specific error code
225+
return -2
226+
elif os.path.isdir(input_file):
208227
file_size_list_obj = 0
209228
# Gets the size if the path is a folder with recursively searching th director<
210229
for root, _dirs, files in os.walk(input_file):
@@ -215,26 +234,23 @@ def get_file_size(input_file: str) -> int:
215234

216235
except (FileNotFoundError, ValueError):
217236
continue
237+
return file_size_list_obj
218238
elif os.path.isfile(input_file):
219239
try:
220-
file_size_list_obj = os.path.getsize(input_file)
240+
return os.path.getsize(input_file)
221241
except (FileNotFoundError, ValueError):
222242
return -1
223243
else:
224-
# Error code
244+
# Error
225245
return -1
226-
if os.path.islink(input_file):
227-
return -2
228-
else:
229-
return file_size_list_obj
230246

231247

232248
# Convert File Size to a String
233249
def conv_file_size(byte_size: int, decimal_places=2) -> str:
234250
if byte_size == -1:
235251
return "ERROR! (File does not exist or isn't valid)"
236252
elif byte_size == -2:
237-
return "ERROR! (File is a Link to an other File)"
253+
return "File is a Link to an other File"
238254
elif byte_size > 1000000000:
239255
return f"{round(byte_size / 1000000000, decimal_places)} GB"
240256
elif byte_size > 1000000:
@@ -285,6 +301,7 @@ def setup():
285301
remove_cache()
286302

287303
# Checking if all settings exist and updating version numbers
304+
settings["cache_version"] = FF_CACHE_VERSION
288305
settings["settings_version"] = FF_SETTINGS_VERSION
289306
settings["version"] = f"{VERSION_SHORT}[{VERSION}]"
290307

0 commit comments

Comments
 (0)