Skip to content

Commit 49fcbbb

Browse files
committed
Apply changes from code review
1 parent 9e9e3fe commit 49fcbbb

File tree

3 files changed

+17
-27
lines changed

3 files changed

+17
-27
lines changed

src/Files.App.Storage/NativeStorage/NativeFolder.cs

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -125,21 +125,19 @@ public async Task<IStorable> MoveFromAsync(IStorable itemToMove, IModifiableFold
125125

126126
if (itemToMove is IFile sourceFile)
127127
{
128-
if (itemToMove is ILocatableFile sourceLocatableFile)
129-
{
130-
var newPath = System.IO.Path.Combine(Path, itemToMove.Name);
131-
File.Move(sourceLocatableFile.Path, newPath, overwrite);
128+
if (itemToMove is ILocatableFile sourceLocatableFile)
129+
{
130+
var newPath = System.IO.Path.Combine(Path, itemToMove.Name);
131+
File.Move(sourceLocatableFile.Path, newPath, overwrite);
132132

133-
return new NativeFile(newPath);
134-
}
135-
else
136-
{
137-
var copiedFile = await CreateFileAsync(itemToMove.Name, collisionOption, cancellationToken);
138-
await sourceFile.CopyContentsToAsync(copiedFile, cancellationToken);
139-
await source.DeleteAsync(itemToMove, true, cancellationToken);
133+
return new NativeFile(newPath);
134+
}
140135

141-
return copiedFile;
142-
}
136+
var copiedFile = await CreateFileAsync(itemToMove.Name, collisionOption, cancellationToken);
137+
await sourceFile.CopyContentsToAsync(copiedFile, cancellationToken);
138+
await source.DeleteAsync(itemToMove, true, cancellationToken);
139+
140+
return copiedFile;
143141
}
144142
else if (itemToMove is IFolder sourceFolder)
145143
{

src/Files.App.Storage/NativeStorage/NativeStorageService.cs

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,19 +18,15 @@ public Task<bool> IsAccessibleAsync(CancellationToken cancellationToken = defaul
1818
/// <inheritdoc/>
1919
public Task<bool> FileExistsAsync(string path, CancellationToken cancellationToken = default)
2020
{
21-
if (File.Exists(path))
22-
return Task.FromResult(true);
23-
24-
return Task.FromResult(false);
21+
var fileExists = File.Exists(path);
22+
return Task.FromResult(fileExists);
2523
}
2624

2725
/// <inheritdoc/>
2826
public Task<bool> DirectoryExistsAsync(string path, CancellationToken cancellationToken = default)
2927
{
30-
if (Directory.Exists(path))
31-
return Task.FromResult(true);
32-
33-
return Task.FromResult(false);
28+
var directoryExists = Directory.Exists(path);
29+
return Task.FromResult(directoryExists);
3430
}
3531

3632
/// <inheritdoc/>

src/Files.App.Storage/WindowsStorage/WindowsStorageService.cs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -47,18 +47,14 @@ public async Task<bool> DirectoryExistsAsync(string path, CancellationToken canc
4747
/// <inheritdoc/>
4848
public async Task<ILocatableFolder> GetFolderFromPathAsync(string path, CancellationToken cancellationToken = default)
4949
{
50-
var folderTask = StorageFolder.GetFolderFromPathAsync(path).AsTask(cancellationToken);
51-
var folder = await folderTask;
52-
50+
var folder = await StorageFolder.GetFolderFromPathAsync(path).AsTask(cancellationToken);
5351
return new WindowsStorageFolder(folder);
5452
}
5553

5654
/// <inheritdoc/>
5755
public async Task<ILocatableFile> GetFileFromPathAsync(string path, CancellationToken cancellationToken = default)
5856
{
59-
var fileTask = StorageFile.GetFileFromPathAsync(path).AsTask(cancellationToken);
60-
var file = await fileTask;
61-
57+
var file = await StorageFile.GetFileFromPathAsync(path).AsTask(cancellationToken);
6258
return new WindowsStorageFile(file);
6359
}
6460
}

0 commit comments

Comments
 (0)