Jira (PUP-9514) tidy: Allow removal of old directories, even if not empty

23 views
Skip to first unread message

Dirk Heinrichs (JIRA)

unread,
Mar 6, 2019, 4:03:03 AM3/6/19
to puppe...@googlegroups.com
Dirk Heinrichs created an issue
 
Puppet / Improvement PUP-9514
tidy: Allow removal of old directories, even if not empty
Issue Type: Improvement Improvement
Assignee: Unassigned
Components: Platform
Created: 2019/03/06 1:02 AM
Priority: Major Major
Reporter: Dirk Heinrichs

The tidy resource currently doesn't allow removal of non-empty directories. But sometimes this is exactly what is needed. For example we have a Windows application which doesn't cleanup after itself and leaves behind lots of directories with name "out-*" which I would like to remove after some days. Unfortunately, those directories are written to the root of drive D:, alongside other directories, which ought to be kept (but shouldn't need to be traversed).

So the approach I'd like to use is:

tidy { 'cleanup_d':
  path =>  'D:/',
  matches => ['out-*'],
  age => '7d',
  recurse => 1,
  rmdirs => true,
}

but this apparently doesn't work because the directories aren't empty.

Please add a "force" property to allow removal of non-empty directories.

Add Comment Add Comment
 
This message was sent by Atlassian JIRA (v7.7.1#77002-sha1:e75ca93)
Atlassian logo

Jorie Tappa (JIRA)

unread,
Mar 18, 2019, 1:21:04 PM3/18/19
to puppe...@googlegroups.com

Josh Cooper (JIRA)

unread,
Jun 19, 2019, 5:26:03 PM6/19/19
to puppe...@googlegroups.com

Josh Cooper (Jira)

unread,
Nov 11, 2021, 12:11:02 AM11/11/21
to puppe...@googlegroups.com
Josh Cooper commented on Improvement PUP-9514
 
Re: tidy: Allow removal of old directories, even if not empty

Tidy already deletes directories when using recurse and rmdirs => true.

# find /tmp/out-1/
/tmp/out-1/
/tmp/out-1/file1
# cat tidy.pp 
tidy { 'cleanup':
  path =>  '/tmp',
  matches => ['out-*'],
  age => '1s',
  recurse => 1,
  rmdirs => true,
}
# puppet apply tidy.pp 
Notice: Compiled catalog for swell-limbo.delivery.puppetlabs.net in environment production in 0.02 seconds
Notice: /Stage[main]/Main/Tidy[cleanup]: Tidying 1 files
Notice: /Stage[main]/Main/File[/tmp/out-1]/ensure: removed
Notice: Applied catalog in 0.01 seconds
# ls /tmp/out-1
ls: cannot access '/tmp/out-1': No such file or directory

And actually, it will delete directories even if they are not empty which is PUP-11334. I'm going to close this as cannot reproduce. Please reopen with --debug output if it is still an issue.

This message was sent by Atlassian Jira (v8.13.2#813002-sha1:c495a97)
Atlassian logo

Dirk Heinrichs (Jira)

unread,
Nov 11, 2021, 2:29:01 AM11/11/21
to puppe...@googlegroups.com

Could this be a Windows-only thing? I see you tested it on Linux. Anyway, I've already moved it into a Powershell script, triggered by a scheduled task.

Dirk Heinrichs (Jira)

unread,
Nov 11, 2021, 5:59:02 AM11/11/21
to puppe...@googlegroups.com

OK, tested on Windows and it's working there, too. Anyway, after more than 2 years I can't remember anymore what exactly wasn't working back then. Thanks Josh Cooper for looking into it.

Reply all
Reply to author
Forward
0 new messages