Skip to content

Commit 8887552

Browse files
authored
Fix google drive detection (#9716)
* Copy wal file * Fix rd.xml for sqlite
1 parent 233224b commit 8887552

File tree

3 files changed

+14
-3
lines changed

3 files changed

+14
-3
lines changed

src/Files.Shared/Extensions/TaskExtensions.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,5 +21,11 @@ public static async Task WithTimeoutAsync(this Task task, TimeSpan timeout)
2121
}
2222
return defaultValue;
2323
}
24+
25+
public static async Task<TOut> AndThen<TIn, TOut>(this Task<TIn> inputTask, Func<TIn, Task<TOut>> mapping)
26+
{
27+
var input = await inputTask;
28+
return (await mapping(input));
29+
}
2430
}
2531
}

src/Files.Uwp/Filesystem/Cloud/Detector/GoogleDriveCloudDetector.cs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using Files.Shared.Cloud;
2+
using Files.Shared.Extensions;
23
using Files.Uwp.Extensions;
34
using Microsoft.Data.Sqlite;
45
using System;
@@ -14,8 +15,11 @@ protected override async IAsyncEnumerable<ICloudProvider> GetProviders()
1415
{
1516
// Google Drive's sync database can be in a couple different locations. Go find it.
1617
string appDataPath = UserDataPaths.GetDefault().LocalAppData;
17-
var configFile = await StorageFile.GetFileFromPathAsync(Path.Combine(appDataPath, @"Google\DriveFS\root_preference_sqlite.db"));
18-
await configFile.CopyAsync(ApplicationData.Current.TemporaryFolder, "google_drive.db", NameCollisionOption.ReplaceExisting);
18+
await StorageFile.GetFileFromPathAsync(Path.Combine(appDataPath, @"Google\DriveFS\root_preference_sqlite.db")).AsTask()
19+
.AndThen(c => c.CopyAsync(ApplicationData.Current.TemporaryFolder, "google_drive.db", NameCollisionOption.ReplaceExisting).AsTask());
20+
// The wal file may not exist but that's ok
21+
await FilesystemTasks.Wrap(() => StorageFile.GetFileFromPathAsync(Path.Combine(appDataPath, @"Google\DriveFS\root_preference_sqlite.db-wal")).AsTask()
22+
.AndThen(c => c.CopyAsync(ApplicationData.Current.TemporaryFolder, "google_drive.db-wal", NameCollisionOption.ReplaceExisting).AsTask()));
1923
var syncDbPath = Path.Combine(ApplicationData.Current.TemporaryFolder.Path, "google_drive.db");
2024

2125
// Build the connection and sql command

src/Files.Uwp/Properties/Default.rd.xml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@
2121
An Assembly element with Name="*Application*" applies to all assemblies in
2222
the application package. The asterisks are not wildcards.
2323
-->
24-
<Assembly Name="SQLitePCL" Dynamic="Required Public" />
24+
<Type Name="SQLitePCL.Batteries_V2" Dynamic="Required Public" />
25+
2526
<Assembly Name="Microsoft.Toolkit.Uwp.Notifications" Dynamic="Required Public" />
2627
<Assembly Name="Microsoft.Xaml.Interactivity" Dynamic="Required Public" />
2728
<Assembly Name="Microsoft.Xaml.Interactions.Core" Dynamic="Required Public" />

0 commit comments

Comments
 (0)