private async Task FromFileToDeleted(string inputFileSubPath, string toFileSubPath, List <FileIndexItem> fileIndexResultsList, List <FileIndexItem> fileIndexItems, DetailView detailView) { // when trying to rename something wrongs var fileName = FilenamesHelper.GetFileName(toFileSubPath); if (!FilenamesHelper.IsValidFileName(fileName)) { fileIndexResultsList.Add(new FileIndexItem { Status = FileIndexItem.ExifStatus.OperationNotSupported }); return; //next } // from/input cache should be cleared var inputParentSubFolder = FilenamesHelper.GetParentPath(inputFileSubPath); _query.RemoveCacheParentItem(inputParentSubFolder); var toParentSubFolder = FilenamesHelper.GetParentPath(toFileSubPath); if (string.IsNullOrEmpty(toParentSubFolder)) { toParentSubFolder = "/"; } // clear cache (to FileSubPath parents) _query.RemoveCacheParentItem(toParentSubFolder); // Check if the parent folder exist in the database await _query.AddParentItemsAsync(toParentSubFolder); // Save in database before change on disk await SaveToDatabaseAsync(fileIndexItems, fileIndexResultsList, detailView, toFileSubPath); // add folder to file system if (!_iStorage.ExistFolder(toParentSubFolder)) { _iStorage.CreateDirectory(toParentSubFolder); fileIndexResultsList.Add(new FileIndexItem(toParentSubFolder) { Status = FileIndexItem.ExifStatus.Ok }); } _iStorage.FileMove(inputFileSubPath, toFileSubPath); MoveSidecarFile(inputFileSubPath, toFileSubPath); // when renaming a folder it should warn the UI that it should remove the source item fileIndexResultsList.Add(new FileIndexItem(inputFileSubPath) { Status = FileIndexItem.ExifStatus.NotFoundSourceMissing }); }
internal async Task <FileIndexItem> AddParentFolder(string subPath) { var item = await _query.GetObjectByFilePathAsync(subPath); // Current item exist if (item != null) { item.Status = FileIndexItem.ExifStatus.Ok; return(item); } // Not on disk if (!_subPathStorage.ExistFolder(subPath)) { return(new FileIndexItem(subPath) { Status = FileIndexItem.ExifStatus.NotFoundSourceMissing }); } // not in db but should add this item = await _query.AddItemAsync(new FileIndexItem(subPath){ IsDirectory = true }); item.SetLastEdited(); item.Status = FileIndexItem.ExifStatus.Ok; item.ImageFormat = ExtensionRolesHelper.ImageFormat.unknown; // also add the parent of this folder await _query.AddParentItemsAsync(subPath); return(item); }
/// <summary> /// Create an new item in the database /// </summary> /// <param name="statusItem">contains the status</param> /// <param name="subPath">relative path</param> /// <returns>database item</returns> private async Task <FileIndexItem> NewItem(FileIndexItem statusItem, string subPath) { // Add a new Item var dbItem = await _newItem.NewFileItem(statusItem); // When not OK do not Add (fileHash issues) if (dbItem.Status != FileIndexItem.ExifStatus.Ok) { return(dbItem); } await _query.AddItemAsync(dbItem); await _query.AddParentItemsAsync(subPath); AddDeleteStatus(dbItem); return(dbItem); }