public override void Do() { //controller.model.Duplicates.RemoveAt(duplicateIndex); allDuplicatesWithFile = new(); for (int i = 0; i < controller.model.Duplicates.Count; i++) { if (controller.model.Duplicates[i].File1Path == deletedFileFilepath || controller.model.Duplicates[i].File2Path == deletedFileFilepath) { allDuplicatesWithFile.Add(new RemovedDuplicate(i, controller.model.Duplicates[i])); } } //If this duplicate is the one currently being viewed unload media for appropriate side if (duplicate == controller.inspectingDuplicate) { (keptSide == Side.Left ? controller.form.mediaViewerRight : controller.form.mediaViewerLeft).UnloadMedia(true); } //Remove all duplicates from duplicates list (possibly raises issues). for (int i = 0; i < allDuplicatesWithFile.Count; i++) { controller.model.Duplicates.Remove(allDuplicatesWithFile[i].Duplicate); } FileSystem.DeleteFile(deletedFileFilepath, UIOption.OnlyErrorDialogs, RecycleOption.SendToRecycleBin); //TODO: Decide if we want to get these properties from Settings or from the model... //if (Settings.Default.DuplicatesMergeFileTags) if (controller.model.MergeFileTags) { FileDetails details = Utilities.GetFileDetails(keptFileFilepath); details.Combine(Utilities.GetFileDetails(deletedFileFilepath)); //if (Settings.Default.DuplicatesOnlyKeepTagsInLibrary) if (controller.model.OnlyKeepTagsThatAreInLibrary) { details.RemoveTagsNotInCollection(Settings.Default.Tags); //This should be fine because duplicates form doesnt mess with the tag collection. } keptFileNewName = details.GenerateFilename(); File.Move(keptFileFilepath, Path.Combine(Path.GetDirectoryName(keptFileFilepath), keptFileNewName)); } Successful = true; base.Do(); }