Skip to content

Fix: Fixed issue where some OneDrive files were automatically downloaded #14597

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

Merged
merged 2 commits into from
Jan 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 1 addition & 12 deletions src/Files.App/Data/Items/ListedItem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -377,7 +377,7 @@ public override string ToString()
public virtual bool IsPythonFile => FileExtensionHelpers.IsPythonFile(ItemPath);
public bool IsPinned => App.QuickAccessManager.Model.FavoriteItems.Contains(itemPath);
public bool IsDriveRoot => ItemPath == PathNormalization.GetPathRoot(ItemPath);
public bool IsElevated => CheckElevationRights();
public bool IsElevationRequired { get; set; }

private BaseStorageFile itemFile;
public BaseStorageFile ItemFile
Expand All @@ -401,17 +401,6 @@ public void UpdateContainsFilesFolders()
{
ContainsFilesOrFolders = FolderHelpers.CheckForFilesFolders(ItemPath);
}

private bool CheckElevationRights()
{
// Avoid downloading file to check elevation
if (SyncStatusUI.LoadSyncStatus)
return false;

return IsShortcut
? ElevationHelpers.IsElevationRequired(((ShortcutItem)this).TargetPath)
: ElevationHelpers.IsElevationRequired(this.ItemPath);
}
}

public class RecycleBinItem : ListedItem
Expand Down
11 changes: 11 additions & 0 deletions src/Files.App/Data/Models/ItemViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1058,6 +1058,7 @@ await dispatcherQueue.EnqueueOrInvokeAsync(() =>
item.SyncStatusUI = CloudDriveSyncStatusUI.FromCloudDriveSyncStatus(syncStatus);
item.FileFRN = fileFRN;
item.FileTags = fileTag;
item.IsElevationRequired = CheckElevationRights(item);
},
Microsoft.UI.Dispatching.DispatcherQueuePriority.Low);

Expand Down Expand Up @@ -1184,6 +1185,16 @@ await SafetyExtensions.IgnoreExceptions(() =>
}
}

private bool CheckElevationRights(ListedItem item)
{
if (item.SyncStatusUI.LoadSyncStatus)
return false;

return item.IsShortcut
? ElevationHelpers.IsElevationRequired(((ShortcutItem)item).TargetPath)
: ElevationHelpers.IsElevationRequired(item.ItemPath);
}

public async Task LoadGitPropertiesAsync(GitItem gitItem)
{
var getStatus = EnabledGitProperties is GitProperties.All or GitProperties.Status && !gitItem.StatusPropertiesInitialized;
Expand Down
2 changes: 1 addition & 1 deletion src/Files.App/Views/Layouts/ColumnLayoutPage.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@
Margin="2"
HorizontalAlignment="Right"
VerticalAlignment="Bottom"
x:Load="{x:Bind IsElevated}"
x:Load="{x:Bind IsElevationRequired}"
Source="{x:Bind ShieldIcon, Mode=OneWay}"
Stretch="Uniform" />
</Grid>
Expand Down
2 changes: 1 addition & 1 deletion src/Files.App/Views/Layouts/DetailsLayoutPage.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -954,7 +954,7 @@
Height="8"
HorizontalAlignment="Right"
VerticalAlignment="Bottom"
x:Load="{x:Bind IsElevated}"
x:Load="{x:Bind IsElevationRequired}"
Source="{x:Bind ShieldIcon, Mode=OneWay}"
Stretch="Uniform" />
</Grid>
Expand Down
6 changes: 3 additions & 3 deletions src/Files.App/Views/Layouts/GridLayoutPage.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@
Margin="14"
HorizontalAlignment="Right"
VerticalAlignment="Bottom"
x:Load="{x:Bind IsElevated}"
x:Load="{x:Bind IsElevationRequired}"
x:Phase="1"
Source="{x:Bind ShieldIcon, Mode=OneWay}"
Stretch="Uniform" />
Expand Down Expand Up @@ -371,7 +371,7 @@
Height="8"
HorizontalAlignment="Right"
VerticalAlignment="Bottom"
x:Load="{x:Bind IsElevated}"
x:Load="{x:Bind IsElevationRequired}"
Source="{x:Bind ShieldIcon, Mode=OneWay}"
Stretch="Uniform" />
</Grid>
Expand Down Expand Up @@ -589,7 +589,7 @@
Height="16"
HorizontalAlignment="Right"
VerticalAlignment="Bottom"
x:Load="{x:Bind IsElevated}"
x:Load="{x:Bind IsElevationRequired}"
x:Phase="1"
Source="{x:Bind ShieldIcon, Mode=OneWay}"
Stretch="Uniform" />
Expand Down