Skip to content

Improves Files.App.Storage #10834

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

Closed
wants to merge 1 commit into from

Conversation

cinqmilleans
Copy link
Contributor

@cinqmilleans cinqmilleans commented Dec 23, 2022

Resolved / Related Issues
Clean Storage code.

Validation
How did you test these changes?

  • Built and ran the app
  • Tested the changes for accessibility

Copy link
Contributor

@QuaintMako QuaintMako left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. I haven't seen any problem.

src/Files.App.Storage/FtpStorage/FtpStorageFolder.cs and src/Files.App.Storage/WindowsStorage/WindowsStorageFolder.cs are alike on some spaces, but I do not think it'd be wise to try to fuse them.

public Task<bool> IsFileSystemAccessibleAsync(CancellationToken cancellationToken = default)
{
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd keep it as is.


private static async Task<AsyncFtpClient> GetClient(string path, CancellationToken cancellationToken = default)
{
using AsyncFtpClient client = path.GetFtpClient();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

using statement here will dispose the client after the method exits. Remove it from here

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Besides, you could refactor the method in FtpStorable.GetFtpClientAsync() - to use a string path parameter, and remove this method

}

public static Task EnsureConnectedAsync(this AsyncFtpClient ftpClient, CancellationToken cancellationToken = default)
public static string GetFtpPath(this string path)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't make GetFtpPath an extension method on string!!!!

@@ -5,7 +5,7 @@ namespace Files.Shared.Helpers
{
public static class PathHelpers
{
public static string GetParentDir(string path)
public static string GetParentDir(this string path)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nooo!!!

@@ -14,7 +14,7 @@ public static string GetParentDir(string path)
return path.Substring(0, index != -1 ? index : path.Length);
}

public static string Combine(string folder, string name)
public static string Combine(this string folder, string name)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"Nooo!!!" here too

{
return Task.FromResult<ILocatableFolder?>(null);
}
=> Task.FromResult<ILocatableFolder?>(null);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Revert this change please :)

public abstract class FtpStorable : ILocatableStorable
{
/// <inheritdoc/>
public string Path { get; protected set; }
public string Id => string.Empty;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fyi, I wouldn't do anything to this for now, as Id will be implemented here. (And in other places as well)


protected AsyncFtpClient GetFtpClient()
protected async Task<AsyncFtpClient> GetFtpClient(CancellationToken cancellationToken = default)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rename to GetFtpClientAsync

: base(path, name)
{
}
public FtpStorageFile(string path, string name) : base(path, name) {}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Revert this change :) (And in other places too)

@d2dyno1 d2dyno1 added the changes requested Changes are needed for this pull request label Dec 27, 2022
@cinqmilleans
Copy link
Contributor Author

@d2dyno1 @yaira2 @QuaintMako This pr has a lot of cancellation requests and conflicts with #10477. I am closing it because it is no longer needed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
changes requested Changes are needed for this pull request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants