RestorationOfErathia (restoration_of_erathia v0.1.0) View Source

Documentation for RestorationOfErathia. The module is designed to assist with restoration of deleted files from hdd.

It is assumed that a tool similar to photorec is used to restore the deleted files. The documentation for using photorec can be found here: https://www.cgsecurity.org/testdisk.pdf

Two things need to be configured: folder path to folder where restored data is and formats that should be separated out of the rest of the restored data.

Link to this section Summary

Functions

Removes duplicated files from all the folders present in a given path

Given 2 folder paths, unique and duplicate, finds all files in duplicate folder that already exist in unique folder, based on hashes. Removes all the files with matching hashes from duplicate folder.

Removes duplicated files inside a folder (using file hash)

Finds all the files that have the specified extension format in a directory and moves them to a directory named after the extension format. Moves all files with unspecified extensions to a merged folder. Test requires specific path setting in module constants.

Removes all empty folders from a given path

Runs the entire helper pipeline

Link to this section Functions

Link to this function

deduplicate_all_folders(path)

View Source

Removes duplicated files from all the folders present in a given path

Link to this function

deduplicate_between_folders(unique_folder_path, duplicate_folder_path)

View Source

Given 2 folder paths, unique and duplicate, finds all files in duplicate folder that already exist in unique folder, based on hashes. Removes all the files with matching hashes from duplicate folder.

Examples

iex> r = RestorationOfErathia
iex> {:ok, wd} = File.cwd()
iex> File.mkdir("#{wd}/tmp")
iex> File.touch("#{wd}/tmp/test.txt")
iex> File.mkdir("#{wd}/tmp2")
iex> File.cp("#{wd}/tmp/test.txt", "#{wd}/tmp2/test.txt")
iex> r.deduplicate_between_folders("#{wd}/tmp", "#{wd}/tmp2")
iex> File.rm("#{wd}/tmp/test.txt")
iex> File.rmdir("#{wd}/tmp")
iex> File.rmdir("#{wd}/tmp2")
:ok
Link to this function

deduplicate_folder(folder_path)

View Source

Removes duplicated files inside a folder (using file hash)

Examples

iex> r = RestorationOfErathia
iex> {:ok, wd} = File.cwd()
iex> File.mkdir("#{wd}/tmp")
iex> File.touch("#{wd}/tmp/test.txt")
iex> File.cp("#{wd}/tmp/test.txt", "#{wd}/tmp/test2.txt")
iex> r.deduplicate_folder("#{wd}/tmp")
iex> File.rm("#{wd}/tmp/test2.txt")
iex> File.rmdir("#{wd}/tmp")
:ok
Link to this function

move_to_dir(filepath, format)

View Source

Finds all the files that have the specified extension format in a directory and moves them to a directory named after the extension format. Moves all files with unspecified extensions to a merged folder. Test requires specific path setting in module constants.

Examples

iex> r = RestorationOfErathia
iex> {:ok, wd} = File.cwd()
iex> File.mkdir("#{wd}/tmp")
iex> File.touch("#{wd}/tmp/test.txt")
iex> r.move_to_dir("#{wd}/tmp/test.txt", "txt")
iex> File.rm("#{wd}/tmp/txt/test.txt")
iex> File.rmdir("#{wd}/tmp/txt")
iex> File.rmdir("#{wd}/tmp")
:ok
Link to this function

remove_empty_folders(path)

View Source

Removes all empty folders from a given path

Examples

iex> r = RestorationOfErathia
iex> {:ok, wd} = File.cwd()
iex> File.mkdir("#{wd}/tmp")
iex> File.mkdir("#{wd}/tmp2")
iex> r.remove_empty_folders("#{wd}")

Runs the entire helper pipeline:

  • Separates data according to folders according to formats.
  • Merges all unset formats to a single folder.
  • Deduplicates files within the folders.
  • Removes empty folders