GithubHelp home page GithubHelp logo

Comments (8)

waliarubal avatar waliarubal commented on June 14, 2024

Seems to me its showing all mount points. This is not at all intended, most likely code needs to be done to just show only removable and fixed media.

from jaya.

Splitwirez avatar Splitwirez commented on June 14, 2024

Seems to me its showing all mount points. This is not at all intended, most likely code needs to be done to just show only removable and fixed media.

Okay, glad to hear it's at least clear to you what the problem is...I wouldn't have had the slightest clue, lol

from jaya.

Splitwirez avatar Splitwirez commented on June 14, 2024

Decided to experiment with fixing this. In Jaya.Provider.FileSystem/Services/FileSystemService.cs, replacing the GetDirectoryAsync function with the following:

        public override async Task<DirectoryModel> GetDirectoryAsync(AccountModelBase account, DirectoryModel directory = null)
        {
            var model = GetFromCache(account, directory);
            if (model != null)
                return model;

            return await Task.Run(() =>
            {
                model = new DirectoryModel();

                if (string.IsNullOrEmpty(directory.Path))
                {
                    model.Directories = new List<DirectoryModel>();
                    if (ServiceLocator.Instance.GetService<IPlatformService>().GetPlatform() == OSPlatform.Linux)
                    {
                        try
                        {
                            foreach (var driveInfo in DriveInfo.GetDrives())
                            {
                                if (!driveInfo.IsReady)
                                    continue;

                                if (driveInfo.Name.Equals("/", StringComparison.OrdinalIgnoreCase))
                                {
                                    var rootDir = new DirectoryModel();
                                    rootDir.Name = driveInfo.Name;
                                    rootDir.Path = driveInfo.RootDirectory.FullName;
                                    
                                    rootDir = GetDirectoryAsync(account, rootDir).Result;
                                    
                                    model.Directories = rootDir.Directories;
                                    model.Files = rootDir.Files;
                                    break;
                                }
                            }
                        }
                        catch (UnauthorizedAccessException)
                        {

                        }
                    }
                    else
                    {
                        foreach (var driveInfo in DriveInfo.GetDrives())
                        {
                            if (!driveInfo.IsReady)
                                continue;

                            var drive = new DirectoryModel(true);
                            drive.Name = driveInfo.Name;
                            drive.Path = driveInfo.RootDirectory.FullName;
                            drive.Size = driveInfo.TotalSize;
                            model.Directories.Add(drive);
                        }
                    }
                    AddToCache(account, model);
                    return model;
                }

                DirectoryInfo info = new DirectoryInfo(directory.Path);
                model.Name = info.Name;
                model.Path = info.FullName;
                model.Created = info.CreationTime;
                model.Modified = info.LastWriteTime;
                model.Accessed = info.LastAccessTime;
                model.IsHidden = info.Attributes.HasFlag(FileAttributes.Hidden);
                model.IsSystem = info.Attributes.HasFlag(FileAttributes.System);

                model.Files = new List<FileModel>();
                try
                {
                    foreach (var fileInfo in info.GetFiles())
                    {
                        var file = new FileModel();
                        if (string.IsNullOrEmpty(fileInfo.Extension))
                            file.Name = fileInfo.Name;
                        else
                        {
                            file.Name = fileInfo.Name.Replace(fileInfo.Extension, string.Empty);
                            file.Extension = fileInfo.Extension.Substring(1).ToLowerInvariant();
                        }
                        file.Path = fileInfo.FullName;
                        file.Size = fileInfo.Length;
                        file.Created = fileInfo.CreationTime;
                        file.Modified = fileInfo.LastWriteTime;
                        file.Accessed = fileInfo.LastAccessTime;
                        file.IsHidden = fileInfo.Attributes.HasFlag(FileAttributes.Hidden);
                        file.IsSystem = fileInfo.Attributes.HasFlag(FileAttributes.System);
                        model.Files.Add(file);
                    }
                }
                catch (UnauthorizedAccessException)
                {

                }

                model.Directories = new List<DirectoryModel>();
                try
                {
                    foreach (var directoryInfo in info.GetDirectories())
                    {
                        var dir = new DirectoryModel();
                        dir.Name = directoryInfo.Name;
                        dir.Path = directoryInfo.FullName;
                        dir.Created = directoryInfo.CreationTime;
                        dir.Modified = directoryInfo.LastWriteTime;
                        dir.Accessed = directoryInfo.LastAccessTime;
                        dir.IsHidden = directoryInfo.Attributes.HasFlag(FileAttributes.Hidden);
                        dir.IsSystem = directoryInfo.Attributes.HasFlag(FileAttributes.System);
                        model.Directories.Add(dir);
                    }
                }
                catch (UnauthorizedAccessException)
                {

                }

                AddToCache(account, model);
                return model;
            });
        }

Seems to produce more desirable results. Is this an acceptable solution?

from jaya.

waliarubal avatar waliarubal commented on June 14, 2024

It should be acceptable if you have tested it with Windows and Mac. If this piece works there without any issues then it should be no problem at all.

from jaya.

Splitwirez avatar Splitwirez commented on June 14, 2024

It should be acceptable if you have tested it with Windows and Mac. If this piece works there without any issues then it should be no problem at all.

Just tested and can verify that it works without a hitch on Windows. Unfortunately, I have no means of testing on macOS...didn't you say you'd picked up an old macbook or something not too long ago?

from jaya.

waliarubal avatar waliarubal commented on June 14, 2024

I picked up a new MacMini 2014 model in July. Will test it on that. Please add your code and push it to the repository since you have access.

from jaya.

Splitwirez avatar Splitwirez commented on June 14, 2024

I picked up a new MacMini 2014 model in July. Will test it on that. Please add your code and push it to the repository since you have access.

Okay, done. Looking forward to those test results.

from jaya.

waliarubal avatar waliarubal commented on June 14, 2024

We are rewriting old codebase, this issue is no more relevant.

from jaya.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.