Skip to content

GitLab

  • Menu
Projects Groups Snippets
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in
  • Trac Trac
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Issues 246
    • Issues 246
    • List
    • Boards
    • Service Desk
    • Milestones
  • Monitor
    • Monitor
    • Metrics
    • Incidents
  • Analytics
    • Analytics
    • Value stream
  • Wiki
    • Wiki
  • Activity
  • Create a new issue
  • Issue Boards
Collapse sidebar
  • Legacy
  • TracTrac
  • Issues
  • #20546

Closed (moved)
(moved)
Open
Created Nov 03, 2016 by iwakeh@iwakeh

Implement CleanUtils class for common file system operations

Create a org.torproject.collector.persist.CleanUtils class, which should offer the methods listed below. First create the corresponding org.torproject.collector.persist.CleanUtilsTest class for all these methods. After that make the tests pass.

Use Files.walkFileTree() and SimpleFileVisitor for the implementation.

  1. Basic clean-up method:
/**
 *  All files in the given directory and below are inspected and
 * erased, if they are older than the given cut-off-time.
*/
public static void cleanDir(Path directory, long cutOffTime) {...}
  1. Remove files with a certain ending:
/**
 *  All files in the given directory and below are inspected and
 * erased, if they are older than the given cut-off-time, and their name
 * ends with one of the given patterns.
*/
public static void cleanDirPattern(Path directory, long cutOffTime,
    String ... endingStrings) {...}
  1. Some renaming methods:
/**
 *  All files in the given directory and below are inspected and renamed
 * from <filename><ending> to <fileneame>, if their name ends with the given
 * 'ending'.
*/
public static void renameFiles(Path directory, String ending) {...}


/**
 *  All files in the given directory and below are inspected and renamed
 * from <filename>.tmp to <fileneame>, if their name ends with '.tmp'.
*/
public static void renameTmpFiles(Path directory) {
  renameFiles(directory, ".tmp");
}
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information
Assignee
Assign to
Time tracking