Commit graph

109 commits

Author SHA1 Message Date
Jack251970
7e332fa615 Refactor caching and indexing logic
Added `ResetCache` calls after clearing `_win32s` and `_uwps` lists to ensure proper cache reset during indexing. Updated logic to return `resultList` after setting cache size and expiration for improved clarity. Removed `await Task.WhenAll` to adjust asynchronous flow in the indexing process.
2025-11-06 15:29:38 +08:00
Jack251970
3d8fd1d352 Improve cancellation, locking, and logging mechanisms
Enhanced cancellation handling by adding `token.IsCancellationRequested` checks to improve responsiveness. Refactored locking mechanisms for `_win32sLock` and `_uwpsLock` using `try-finally` blocks to ensure proper acquisition and release, improving thread safety and preventing deadlocks.

Reorganized Win32 and UWP program querying logic for better modularity and readability. Replaced shared collection access with local variables to improve clarity and maintain thread safety. Simplified empty result handling by directly returning `emptyResults` when canceled.

Removed redundant debug log statements to reduce verbosity and updated remaining logs for clarity. Suppressed unused result warnings by replacing direct calls to `EverythingApiDllImport.Everything_GetMajorVersion()` with null-coalescing assignments.
2025-11-06 15:28:13 +08:00
Jack251970
db0c86d50c Remove CancellationToken from semaphore WaitAsync calls
Removed the `CancellationToken` parameter from `WaitAsync` calls
on semaphores in `EverythingAPI.cs` and `Main.cs`. This change
eliminates cancellation support for semaphore waits, likely due
to a design decision prioritizing simplicity or avoiding issues
with cancellation handling.

In `EverythingAPI.cs`, `WaitAsync(token)` was replaced with
`WaitAsync()` in two methods. Similarly, in `Main.cs`, the
`WaitAsync` calls for `_win32sLock` and `_uwpsLock` were updated
to remove the `token` parameter.

Note: This change may impact the ability to gracefully handle
cancellation during semaphore waits.
2025-11-04 14:25:55 +08:00
Jack251970
6e17d5d756 Improve logging for Win32 program lock acquisition
Added a debug log statement to indicate when the lock for
querying Win32 programs is being acquired. This enhances
granularity in logging, making it easier to distinguish
between the acquisition of locks for Win32 and UWP programs.
Improves traceability and debugging of the program's
execution flow.
2025-11-04 12:27:59 +08:00
Jack251970
4cf942ac3a Add detailed debug logging for query execution process
Enhanced logging to provide better traceability and insights:
- Added debug logs for query reception, cache misses, and lock acquisition.
- Logged query cancellation and completion with result counts.
- Added logs for caching results, including item counts and query details.
- Improved logging for filtering and program selection processes.
- Ensured no functional changes to existing query and filtering logic.
2025-10-26 21:01:07 +08:00
Jack251970
f632a4b773 Add caching to QueryAsync and integrate cache reset logic
Introduced a MemoryCache to improve QueryAsync performance by
caching query results, reducing redundant computations. Added
a ResetCache method to reinitialize the cache when settings
are updated. Integrated cache reset calls into settings
property setters to ensure consistency.

Refactored query logic to leverage MemoryCache.GetOrCreateAsync
for streamlined caching. Removed redundant code and debug
logging for improved readability and maintainability. Ensured
thread safety with proper locking mechanisms. Simplified and
consolidated caching logic for better maintainability.
2025-10-26 20:59:29 +08:00
Jack251970
e2fa122362 Improve program indexing with logging and thread safety
Added detailed debug logging to `IndexWin32ProgramsAsync` and
`IndexUwpProgramsAsync` to track the indexing process, including
preparation, start, retrieval, caching, and completion.

Replaced direct updates to `_settings.LastIndexTime` with a
thread-safe lock to prevent race conditions.

Enhanced `IndexProgramsAsync` with a debug log to indicate the
start of indexing for better traceability.

Updated program retrieval logic to process Win32 and UWP programs
in parallel with cancellation support and applied the
`HideUninstallersFilter` for cleaner results.
2025-10-26 20:56:08 +08:00
Jack251970
6a65f8090f Enhance thread safety and refactor reindexing logic
Introduced `_lastIndexTimeLock` to ensure thread-safe access
and updates to `_settings.LastIndexTime`, preventing race
conditions. Refactored reindexing logic to use a `lock` block
for evaluating and updating the reindexing condition.

Added `emptyResults` as a static readonly placeholder list.
Improved code clarity and maintainability without altering
existing functionality.
2025-10-26 20:51:08 +08:00
Jack251970
637d926f7a Remove caching logic and initialize emptyResults list
The caching-related code, including `cacheOptions` and `cache`, has been removed from `Main.cs`, indicating that the caching mechanism is no longer in use or has been refactored elsewhere. Additionally, the `emptyResults` list is now explicitly initialized as an empty list (`[]`). No changes were made to the `Context` property or the `commonUninstallerNames` array.
2025-10-26 20:41:06 +08:00
Jack251970
7f5efc5ca1 Refactor caching and improve QueryAsync method
Removed the `ResetCache` method and its associated calls to streamline caching management and improve performance. Refactored the `QueryAsync` method for better thread safety, synchronization, and exception handling. Simplified UWP and Win32 program filtering logic and removed redundant code. Eliminated manual cache disposal and reset logic, favoring a more efficient and automated caching mechanism. These changes enhance maintainability, responsiveness, and overall plugin performance.
2025-10-26 20:40:37 +08:00
Jack251970
ef69e329fc Fix release 2025-09-15 15:50:22 +08:00
Jack251970
9321a7df14 Fix program lock issue 2025-09-15 15:40:49 +08:00
Jack Ye
ed0524d207
Merge branch 'dev' into code_quality 2025-07-20 20:02:51 +08:00
Jack251970
d71d3a5094 Fix build issue 2025-07-20 12:57:56 +08:00
Jack Ye
e931f3ae41
Fix translations
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
2025-07-20 12:57:04 +08:00
Jack251970
ba0a113cc9 Add translations & Use ShowMsgError 2025-07-20 12:28:55 +08:00
Jack Ye
fc6ff5a7a0
Merge branch 'dev' into code_quality 2025-07-14 09:09:09 +08:00
Jack251970
80b7775412 Return results when query is empty for program 2025-07-04 10:50:50 +08:00
Jack251970
c4cbf941cf Add directory null check 2025-06-23 13:13:45 +08:00
Jack251970
68fc103d7f Use trick to get the cache directory path 2025-06-23 12:45:31 +08:00
Jack251970
3f57f944f6 Remove useless debug 2025-04-13 17:52:42 +08:00
Jack251970
4f246460c3 Fix build issue 2025-04-09 16:46:13 +08:00
Jack Ye
ab34e83c5e
Merge branch 'dev' into 250320BookmarkFavicon 2025-04-09 16:41:28 +08:00
Jack Ye
f5de5d70db
Fix log message issue
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
2025-04-09 13:08:28 +08:00
Jack251970
826bc42536 Improve code quality 2025-04-09 12:44:26 +08:00
Jack251970
9c07989edf Improve code quality 2025-04-09 12:14:07 +08:00
Jack251970
24d43ed84b Use api functions in Program plugin 2025-04-08 21:46:02 +08:00
Jack251970
482e37316a Remove useless releases 2025-04-08 19:46:40 +08:00
Jack251970
d7ca36e60a Change variable name 2025-04-08 19:44:30 +08:00
Jack251970
2ff09cf9b0 Improve code quality 2025-04-08 19:41:02 +08:00
Jack251970
4c4a6c0e22 Add log handler for indexing 2025-04-08 19:27:53 +08:00
Jack251970
68268026de Improve performance 2025-04-08 19:21:03 +08:00
Jack251970
c11ee2f9e7 Improve code quality & comments & Fix lock issue 2025-04-08 17:20:57 +08:00
Jack251970
734c5bb67d Fix lock release issue 2025-04-08 16:59:27 +08:00
Jack251970
7da2884e84 Add locks for win32s & uwps 2025-04-08 16:29:03 +08:00
Jack Ye
8cd81b74f9
Merge branch 'dev' into binary_storage_api 2025-04-04 16:41:08 +08:00
Jack251970
44ba60cdfc Move ValidateDirectory functions to FileFolders for plugin usage 2025-04-02 20:17:32 +08:00
Jack251970
0496d6c04a Use api functions for Program plugin 2025-04-01 14:21:29 +08:00
Jack251970
fe86e23dea Add exception handles 2025-02-24 16:11:49 +08:00
Jack251970
a0c2a42e17 Let Program plugin use plugin cache path 2025-02-24 15:15:26 +08:00
Jeremy Wu
4b03aa477c
Merge pull request #3240 from Jack251970/back_query_results_before_change_query
Fix ChangeQuery & ReQuery Work Issue When Results Are Not From Query Results
2025-02-23 10:13:11 +11:00
Jack251970
aee585620a Remove back to query result and call this function in ChangeQuery & ReQuery 2025-02-22 19:32:08 +08:00
Jack251970
79bcf8be18 Use system environment for Windows app path 2025-02-21 09:32:58 +08:00
Jack251970
097633e9e0 Fix typos 2025-02-21 09:29:43 +08:00
Jack251970
ccf8d876ae Add support for hiding dulplicated windows apps 2025-02-20 14:59:16 +08:00
Jack251970
1562c88ea7 Improve context menu item action response 2025-01-26 20:07:40 +08:00
Jeremy Wu
0c7dc07c74
fix typo 2025-01-26 09:34:07 +11:00
Jack251970
71dad9f356 Add support for more uninstaller prefixs 2025-01-24 18:35:11 +08:00
Jack251970
fec553c87c Improve uninstaller check function 2025-01-24 12:11:48 +08:00
Jack251970
9cb464df05 Add debug log for exception. 2024-11-24 09:21:27 +08:00