charon-0.1: Template
Safe HaskellSafe-Inferred
LanguageGHC2021

Charon.Backend.Default.Trash

Description

Interface for the default trash directory

Synopsis

Trash directory

createTrash :: (HasCallStack, HasTrashHome env, MonadLoggerNS m, MonadPathWriter m, MonadReader env m) => m (PathI TrashDirFiles, PathI TrashDirInfo) Source #

Creates the trash directory if it does not exist.

createTrashDir :: (HasCallStack, MonadLoggerNS m, MonadPathWriter m) => PathI TrashHome -> m (PathI TrashDirFiles, PathI TrashDirInfo) Source #

Creates the trash directory if it does not exist.

doesTrashExist :: (HasCallStack, HasTrashHome env, MonadLoggerNS m, MonadPathReader m, MonadReader env m, MonadThrow m) => m Bool Source #

Returns False if <trash-home> does not exist. If <trash-home> does exist but is "badly-formed" i.e. one of

  • <trash-home>/files
  • <trash-home>/info

does not, throws TrashDirFilesNotFoundE or TrashDirInfoNotFoundE.

If all three dirs exist, returns True.

doesTrashExistPath :: (HasCallStack, MonadLoggerNS m, MonadPathReader m, MonadThrow m) => PathI TrashHome -> m Bool Source #

Returns False if <trash-home> does not exist. If <trash-home> does exist but is "badly-formed" i.e. one of

  • <trash-home>/files
  • <trash-home>/info

does not, throws TrashDirFilesNotFoundE or TrashDirInfoNotFoundE.

If all three dirs exist, returns True.

Main actions

mvOriginalToTrash :: (HasCallStack, Is k A_Getter, LabelOptic' "fileName" k pd (PathI TrashEntryFileName), LabelOptic' "originalPath" k pd (PathI TrashEntryOriginalPath), MonadCatch m, MonadFileWriter m, MonadLoggerNS m, MonadPathWriter m, Serial pd, Show pd) => BackendArgs m pd -> PathI TrashHome -> Timestamp -> PathI TrashEntryOriginalPath -> m (pd, PathTypeW, PathI TrashEntryPath) Source #

Moves the PathData's originalPath to the trash. Returns the created pd.

restoreTrashToOriginal :: (DecodeExtra pd ~ PathI TrashEntryFileName, HasCallStack, Is k A_Getter, LabelOptic' "fileName" k pd (PathI TrashEntryFileName), MonadCatch m, MonadFileReader m, MonadIORef m, MonadLoggerNS m, MonadPathReader m, MonadPathWriter m, MonadTerminal m, Serial pd, Show pd) => BackendArgs m pd -> (PathData -> m ()) -> PathI TrashHome -> PathI TrashEntryFileName -> m (Maybe SomeException) Source #

Moves the PathData's fileName back to its originalPath. Returns True if any failed. In this case, the error has already been reported, so this is purely for signaling (i.e. should we exit with an error).

permDeleteFromTrash :: forall m pd k. (DecodeExtra pd ~ PathI TrashEntryFileName, HasCallStack, Is k A_Getter, LabelOptic' "fileName" k pd (PathI TrashEntryFileName), MonadAsync m, MonadCatch m, MonadFileReader m, MonadHandleWriter m, MonadIORef m, MonadLoggerNS m, MonadPathReader m, MonadPathWriter m, MonadTerminal m, Serial pd, Show pd) => BackendArgs m pd -> (PathData -> m ()) -> Bool -> PathI TrashHome -> PathI TrashEntryFileName -> m (Maybe SomeException) Source #

Permanently deletes the trash path. Returns True if any deletes fail. In this case, the error has already been reported, so this is purely for signaling (i.e. should we exit with an error).

Transformations

mergeTrashDirs Source #

Merges source into dest, failing if there are any collisions.

Utils