Skip to content

Commit

Permalink
Updated implementation to not return directories for get file info
Browse files Browse the repository at this point in the history
  • Loading branch information
niemyjski committed Mar 14, 2024
1 parent 3084d5e commit 15a66ab
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -179,19 +179,33 @@ public virtual async Task WillNotReturnDirectoryInGetPagedFileListAsync()
Assert.False(result.HasMore);
Assert.Empty(result.Files);

const string directory = "EmptyDirectory";
var client = storage is ScopedFileStorage { UnscopedStorage: SshNetFileStorage sshNetStorage }
? sshNetStorage.GetClient()
: null;
Assert.NotNull(client);

client.CreateDirectory("storage/EmptyFolder");
client.CreateDirectory($"storage/{directory}");

result = await storage.GetPagedFileListAsync();
Assert.False(result.HasMore);
Assert.Empty(result.Files);
Assert.False(await result.NextPageAsync());
Assert.False(result.HasMore);
Assert.Empty(result.Files);

// Ensure the directory will not be returned via get file info
var info = await storage.GetFileInfoAsync(directory);
Assert.Null(info?.Path);

// Ensure delete files can remove all files including fake folders
await storage.DeleteFilesAsync("*");

// Assert folder was removed by Delete Files
Assert.False(client.Exists($"storage/{directory}"));

info = await storage.GetFileInfoAsync(directory);
Assert.Null(info);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -179,17 +179,31 @@ public virtual async Task WillNotReturnDirectoryInGetPagedFileListAsync()
Assert.False(result.HasMore);
Assert.Empty(result.Files);

const string directory = "EmptyDirectory";
var client = storage is ScopedFileStorage { UnscopedStorage: SshNetFileStorage sshNetStorage } ? sshNetStorage.GetClient() : null;
Assert.NotNull(client);

client.CreateDirectory("storage/EmptyFolder");
client.CreateDirectory($"storage/{directory}");

result = await storage.GetPagedFileListAsync();
Assert.False(result.HasMore);
Assert.Empty(result.Files);
Assert.False(await result.NextPageAsync());
Assert.False(result.HasMore);
Assert.Empty(result.Files);

// Ensure the directory will not be returned via get file info
var info = await storage.GetFileInfoAsync(directory);
Assert.Null(info?.Path);

// Ensure delete files can remove all files including fake folders
await storage.DeleteFilesAsync("*");

// Assert folder was removed by Delete Files
Assert.False(client.Exists($"storage/{directory}"));

info = await storage.GetFileInfoAsync(directory);
Assert.Null(info);
}
}
}

0 comments on commit 15a66ab

Please sign in to comment.