Skip to content

Commit f2c53fa

Browse files
committed
Feature: Only show Google Drive under cloud drives
1 parent f42f2ea commit f2c53fa

File tree

4 files changed

+19
-3
lines changed

4 files changed

+19
-3
lines changed

src/Files.App/Data/Models/AppModel.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,5 +71,15 @@ public bool ForceProcessTermination
7171
get => forceProcessTermination;
7272
set => SetProperty(ref forceProcessTermination, value);
7373
}
74+
75+
private string googleDrivePath = string.Empty;
76+
/// <summary>
77+
/// Gets or sets a value indicating the path for Google Drive.
78+
/// </summary>
79+
public string GoogleDrivePath
80+
{
81+
get => googleDrivePath;
82+
set => SetProperty(ref googleDrivePath, value);
83+
}
7484
}
7585
}

src/Files.App/Services/RemovableDrivesService.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ public IStorageDeviceWatcher CreateWatcher()
1919
public async IAsyncEnumerable<ILocatableFolder> GetDrivesAsync()
2020
{
2121
var list = DriveInfo.GetDrives();
22+
var googleDrivePath = App.AppModel.GoogleDrivePath;
2223

2324
foreach (var drive in list)
2425
{
@@ -41,6 +42,10 @@ public async IAsyncEnumerable<ILocatableFolder> GetDrivesAsync()
4142
var label = DriveHelpers.GetExtendedDriveLabel(drive);
4243
var driveItem = await DriveItem.CreateFromPropertiesAsync(res.Result, drive.Name.TrimEnd('\\'), label, type, thumbnail);
4344

45+
// Don't add here because Google Drive is already displayed under cloud drives
46+
if (drive.Name == googleDrivePath)
47+
continue;
48+
4449
App.Logger.LogInformation($"Drive added: {driveItem.Path}, {driveItem.Type}");
4550

4651
yield return driveItem;

src/Files.App/Utils/Cloud/Detector/GoogleDriveCloudDetector.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
// Copyright (c) 2023 Files Community
22
// Licensed under the MIT License. See the LICENSE.
33

4-
using Files.Core.Utils.Cloud;
54
using Microsoft.Data.Sqlite;
65
using System.IO;
76
using Windows.Storage;
@@ -57,6 +56,8 @@ await FilesystemTasks.Wrap(() => StorageFile.GetFileFromPathAsync(Path.Combine(a
5756
var folder = await StorageFolder.GetFolderFromPathAsync(path);
5857
string title = reader["title"]?.ToString() ?? folder.Name;
5958

59+
App.AppModel.GoogleDrivePath = path;
60+
6061
yield return new CloudProvider(CloudProviders.GoogleDrive)
6162
{
6263
Name = $"Google Drive ({title})",
@@ -77,6 +78,8 @@ await FilesystemTasks.Wrap(() => StorageFile.GetFileFromPathAsync(Path.Combine(a
7778
string title = reader["name"]?.ToString() ?? folder.Name;
7879
string iconPath = Path.Combine(Environment.GetEnvironmentVariable("ProgramFiles"), "Google", "Drive File Stream", "drive_fs.ico");
7980

81+
App.AppModel.GoogleDrivePath = path;
82+
8083
StorageFile iconFile = await FilesystemTasks.Wrap(() => StorageFile.GetFileFromPathAsync(iconPath).AsTask());
8184

8285
yield return new CloudProvider(CloudProviders.GoogleDrive)

src/Files.Core/Services/Settings/IAppSettingsService.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
// Copyright (c) 2023 Files Community
22
// Licensed under the MIT License. See the LICENSE.
33

4-
using System.ComponentModel;
5-
64
namespace Files.Core.Services.Settings
75
{
86
public interface IAppSettingsService : IBaseSettingsService, INotifyPropertyChanged

0 commit comments

Comments
 (0)