Skip to content

Refactor service ISizeProvider to Backend #9288

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 10 commits into from
Jun 9, 2022

Conversation

cinqmilleans
Copy link
Contributor

The service IFolderSizeProvider is refactored and moved to backend.

  • Rename interface and eventargs for genericity.
  • Use ulong instead long as all sizes in the backend.
  • Use enum instead negative value for no value.
  • Divides the implementation into multiple implementations to separate responsibilities (User parameter management, separation by drives, cache, and soon persistent storage).
  • Uses one instance per drive for performance. Each disk has its own ConcurrentDictionary, so a disk with few files is not hampered by the many files in C:.
  • Move NativeFindStorageItemHelper to backend because the service uses it.

Thanks to @gave92 for fixing and improving this code. All of these improvements are retained.

@gave92
Copy link
Member

gave92 commented Jun 4, 2022

This looks good. Could you just clarify the need for DrivesSizeProvider? The time for retrieving a value from a Dictionary does not depends on the size of the Dictionary.

The Dictionary(Of TKey, TValue) generic class provides a mapping from a set of keys to a set of values. Each addition to the dictionary consists of a value and its associated key. Retrieving a value by using its key is very fast, close to O(1), because the Dictionary(Of TKey, TValue) class is implemented as a hash table.

@cinqmilleans
Copy link
Contributor Author

@gave92 Regarding the speed of reading a dictionary, I don't know if the size decreases the performance. I guess so, but let's say no. Another reason is to be able to use a different implementation depending on the drive.

I am currently working on another implementation of ISizeProvider which stores data persistently in an sqlite database. I was able to get a unique guid (recent commit) but there are cases where it doesn't work, e.g. network disk in linux. A solution to this problem may exist.

My idea is to use for each drive one of the 2 implementations (persistent or not). A single instance can be used for each of the 2 implementations. Soon DrivesSizeProvider will use a service to get the correct implementation for each drive.

@gave92 gave92 added the ready to merge Pull requests that are approved and ready to merge label Jun 4, 2022
@gave92 gave92 self-requested a review June 4, 2022 10:33
gave92
gave92 previously approved these changes Jun 4, 2022
@gave92
Copy link
Member

gave92 commented Jun 4, 2022

Sounds good, for the database you may want to look at LiteDB which is how file tags are stored instead of SQLite.

@cinqmilleans
Copy link
Contributor Author

@gave92 I fixed a problem in this already approved pr. The cache could be cleared unnecessarily.

I try LiteDB.

@yaira2 yaira2 merged commit 9989a5a into files-community:main Jun 9, 2022
@d2dyno1
Copy link
Member

d2dyno1 commented Oct 23, 2022

Hmm

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ready to merge Pull requests that are approved and ready to merge
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants