Skip to content

Directory for every file extension (Better organization)#2

Open
steffalon wants to merge 2 commits intoLennardF1989:masterfrom
steffalon:master
Open

Directory for every file extension (Better organization)#2
steffalon wants to merge 2 commits intoLennardF1989:masterfrom
steffalon:master

Conversation

@steffalon
Copy link

This will prevent users to fetch everything at once in a single directory.

There is a list that keeps track of all existing file types. After building an entry list, it will create separate directories with extension names.

@LinkOFF7
Copy link

LinkOFF7 commented Jan 24, 2021

Temporary solve:
var pathToExtract = $"{outputDirectory}/{fileExtension.ToUpper()}";
if (!Directory.Exists(pathToExtract)) Directory.CreateDirectory(pathToExtract);
File.WriteAllBytes(Path.Combine(pathToExtract, $"{fileEntry.Hash:X16}.{fileExtension.ToLower()}"), bytes);

@LennardF1989
Copy link
Owner

@LinkOFF7 Thanks, but that would cause excessive IO checks. @steffalon version is a one-off thing for that.

I'd have to look into the best approach here, even when you put all files in a folder based on their types, some folders would still contain thousands of files.

@LinkOFF7
Copy link

LinkOFF7 commented Jan 24, 2021

Maybe like that (begin of ExtractFileEntryList function):
foreach(var ext in fileEntryList)
{
var extension = new string(ext.FileType.ToCharArray().Reverse().ToArray());
Directory.CreateDirectory($"{outputDirectory}/{extension}");
}

@steffalon
Copy link
Author

Maybe creating more sub directories based on 2 hex values of a file name? For example:

/JSON
   /FF
   /0E

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants