[Peek] Open file in Read only (#25945)

* Only open FilStream in read-only mode; Release propertyStore handle after getting the file properties

(cherry picked from commit 3b1481da2c)

* Update calls to PropertyStoreHelper

* Add disposable property store

* Make GetPropertyStoreFromPath return Disposable property store

* correct typo

* correct typo

* Remove nullable in DisposablePropertyStore

* Add property getters

* Remove usued method

* Correct typo

* Correct typo again...

* Update description
This commit is contained in:
Yawen Hou
2023-05-10 19:00:13 -04:00
committed by GitHub
parent 648f30d1ab
commit 83574c578a
9 changed files with 98 additions and 70 deletions

View File

@@ -3,7 +3,9 @@
// See the LICENSE file in the project root for more information.
using System;
using System.Runtime.InteropServices;
using System.Threading.Tasks;
using Peek.Common.Extensions;
using Peek.Common.Helpers;
using Windows.Storage;
@@ -15,18 +17,13 @@ namespace Peek.Common.Models
{
private StorageFile? storageFile;
private Lazy<IPropertyStore> _propertyStore;
public FileItem(string path)
{
Path = path;
_propertyStore = new(() => PropertyStoreHelper.GetPropertyStoreFromPath(Path));
}
public string Path { get; init; }
public IPropertyStore PropertyStore => _propertyStore.Value;
public async Task<IStorageItem?> GetStorageItemAsync()
{
return await GetStorageFileAsync();