Jaya
Jaya copied to clipboard
Possible Filesystem disorganization on Linux?
So I've finally switched over to Linux, and upon building and running Jaya, I was greeted by this mess:
...is this the intended result?
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.
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
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?
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.
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?
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.
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.
We are rewriting old codebase, this issue is no more relevant.