charon-0.1: Template
Safe HaskellSafe-Inferred
LanguageGHC2021

Charon.Backend.Default

Description

This module (and sub-hierarchy) provides logic that can be used by any backend (i.e. cbor, fdo, json) that has the following structure:

  trashpaths (paths)
  trashinfo  (info files)

The only difference is in the (de)serialization.

Synopsis

Delete

delete :: forall m env pd k. (HasCallStack, Is k A_Getter, LabelOptic' "fileName" k pd (PathI TrashEntryFileName), LabelOptic' "originalPath" k pd (PathI TrashEntryOriginalPath), HasTrashHome env, MonadCatch m, MonadFileWriter m, MonadIORef m, MonadLoggerNS m, MonadPathWriter m, MonadReader env m, MonadTerminal m, MonadTime m, Serial pd, Show pd) => BackendArgs m pd -> UniqueSeqNE (PathI TrashEntryOriginalPath) -> m () Source #

delete trash p moves path p to the given trash location trash and writes an entry in the trash index. If the trash location is not given, defaults to XDG data e.g. ~/.localsharecharon/.

deletePostHook :: forall m env pd k. (HasCallStack, Is k A_Getter, LabelOptic' "fileName" k pd (PathI TrashEntryFileName), LabelOptic' "originalPath" k pd (PathI TrashEntryOriginalPath), HasTrashHome env, MonadCatch m, MonadFileWriter m, MonadIORef m, MonadLoggerNS m, MonadPathWriter m, MonadReader env m, MonadTerminal m, MonadTime m, Serial pd, Show pd) => BackendArgs m pd -> ((pd, PathTypeW, PathI TrashEntryPath) -> m ()) -> UniqueSeqNE (PathI TrashEntryOriginalPath) -> m () Source #

delete that takes a callback that runs on the created path data, assuming the delete succeeded.

Restore

restore :: forall m env pd k. (DecodeExtra pd ~ PathI TrashEntryFileName, HasCallStack, HasTrashHome env, Is k A_Getter, LabelOptic' "fileName" k pd (PathI TrashEntryFileName), MonadCatch m, MonadFileReader m, MonadIORef m, MonadLoggerNS m, MonadPathReader m, MonadPathWriter m, MonadReader env m, MonadTerminal m, Serial pd, Show pd) => BackendArgs m pd -> UniqueSeqNE (PathI TrashEntryFileName) -> m () Source #

restore trash p restores the trashed path <trash>/p to its original location.

restorePostHook :: forall m env pd k. (DecodeExtra pd ~ PathI TrashEntryFileName, HasCallStack, HasTrashHome env, Is k A_Getter, LabelOptic' "fileName" k pd (PathI TrashEntryFileName), MonadCatch m, MonadFileReader m, MonadIORef m, MonadLoggerNS m, MonadPathReader m, MonadPathWriter m, MonadReader env m, MonadTerminal m, Serial pd, Show pd) => BackendArgs m pd -> (PathData -> m ()) -> UniqueSeqNE (PathI TrashEntryFileName) -> m () Source #

restore trash p restores the trashed path <trash>/p to its original location.

Information

getIndex :: forall m env pd k. (DecodeExtra pd ~ PathI TrashEntryFileName, HasCallStack, HasTrashHome env, Is k A_Getter, LabelOptic' "fileName" k pd (PathI TrashEntryFileName), MonadCatch m, MonadFileReader m, MonadPathReader m, MonadLoggerNS m, MonadReader env m, Serial pd) => BackendArgs m pd -> m Index Source #

Reads the index at either the specified or default location. If the file does not exist, returns empty.

getMetadata :: forall m env pd k. (DecodeExtra pd ~ PathI TrashEntryFileName, HasCallStack, HasTrashHome env, Is k A_Getter, LabelOptic' "fileName" k pd (PathI TrashEntryFileName), MonadCatch m, MonadFileReader m, MonadLoggerNS m, MonadPathReader m, MonadReader env m, Serial pd) => BackendArgs m pd -> m Metadata Source #

Retrieves metadata for the trash directory.

Transformations