commons-io icon indicating copy to clipboard operation
commons-io copied to clipboard

[IO-596] Add DeleteFiles utility class

Open jvz opened this issue 6 years ago • 9 comments

This class provides configurable strategies to delete files and directories.

Adapted from the work done in https://github.com/jenkinsci/jenkins/pull/3812.

Signed-off-by: Matt Sicker [email protected]

@reviewbybees @garydgregory @jeffret-b

jvz avatar Dec 26 '18 23:12 jvz

Note that the build is failing as there is currently an existing unit test that tests a non-existent method.

jvz avatar Dec 26 '18 23:12 jvz

Some of this PR is likely obsolete due to the newer PathUtils delete methods. Please review these and perhaps propose enhancements?

garydgregory avatar Aug 15 '20 03:08 garydgregory

Hi All,

For the basic operations, please use version 2.7's IOExceptionList and PathUtils methods:

  • delete(Path)
  • delete(Path, DeleteOption...)
  • deleteDirectory(Path)
  • deleteDirectory(Path, DeleteOption...)
  • deleteFile(Path)
  • deleteFile(Path, DeleteOption...)

WRT:

  • maxRetries
  • waitBetweenRetriesMillis
  • backoffMultiplier
  • retryOverridingFileAttributes
  • overrideAllAttributes

Perhaps these attributes could encapsulated in a new CopyStrategy implements DeleteOption, CopyOption class (where deleting is a kind of copying [to the bit bucket]) which could then be used by both delete and copy methods in PathUtils?

WDYT?

garydgregory avatar Sep 02 '20 14:09 garydgregory

Breaking up into execution strategies sounds like a good idea! Such a strategy could likely adopt a similar API to retry libraries like retry4j.

jvz avatar Sep 02 '20 14:09 jvz

@jvz Nice idea Matt :-) let's discuss on the ML where a retry API belongs.

garydgregory avatar Sep 03 '20 12:09 garydgregory

On Wed, Sep 2, 2020 at 10:57 AM Matt Sicker [email protected] wrote:

Breaking up into execution strategies sounds like a good idea! Such a strategy could likely adopt a similar API to retry libraries like retry4j.

I am cutting 2.8.0-RC2 now, so let's think about this for 2.9.0.

Gary

— You are receiving this because you modified the open/close state. Reply to this email directly, view it on GitHub https://github.com/apache/commons-io/pull/72#issuecomment-685792005, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAJB6NYP6MQVO34A72S3TSTSDZMNXANCNFSM4GMIUKMA .

garydgregory avatar Sep 06 '20 13:09 garydgregory

Another item: values like waitBetweenRetriesMillis are error prone in my experience. Over at HttpComponents, we have classes called TimeValue and Timeout that wrap a long and a TimeUnit, and I'd like to bring that in to Apache Commons, someplace...

garydgregory avatar Sep 11 '20 21:09 garydgregory

Some of this is superseded by the new(ish) code in PathUtils.delete methods and associated utilities. If we want a retry (count/duration delay) feature, let's build it on top of the newer code.

garydgregory avatar Sep 07 '21 13:09 garydgregory

Hi @jvz May you check PathUtils delete methods and related classes in git master and base further enhancements on that? I'll probably get a new release candidate out in a week or two. So this could be for this or the next release.

garydgregory avatar Oct 19 '21 17:10 garydgregory