public async Task DoAFileMove() { CreateTestFile(); var result = await FileWithProgress.MoveAsync(TestFilePath, TestDestinationPath, ProgressUpdater); Assert.IsTrue(result); Assert.IsTrue(File.Exists(TestDestinationPath)); Assert.IsFalse(File.Exists(TestFilePath)); }
internal async Task <bool> CopyAsync(string sourcePath, string destinationPath, Action <decimal> updateProgressBar) { this.IsCancelled = false; this.UpdateProgressAsPct = updateProgressBar; try { _isMoving = true; return(await FileWithProgress.CopyAsync(sourcePath, destinationPath, ProgressCallback, this)); } finally { _isMoving = false; } }
public static FileWithProgress GetUserFileProgress(string userId, Guid fileId) { using (var db = new HonyomiContext()) { IndexedFile file = db.Files.Include(x => x.Book).ThenInclude(x => x.Files) .SingleOrDefault(x => x.IndexedFileId == fileId); if (file == null) { //bail when such a file does not exist return(null); } FileWithProgress result = new FileWithProgress { Guid = fileId, Title = file.Title, BookGuid = file.BookId, BookTitle = file.Book.Title, TrackIndex = file.TrackIndex, MediaType = file.MimeType, Duration = file.Duration, NextFile = file.Book.Files.FirstOrDefault(x => x.TrackIndex == file.TrackIndex + 1)?.IndexedFileId ?? Guid.Empty }; FileProgress fProg = db.FileProgresses.SingleOrDefault(x => x.FileId == fileId && x.UserId == userId); if (fProg == null) { result.ProgressSeconds = 0; } else { result.ProgressSeconds = fProg.Progress; } return(result); } }