See: https://bugzilla.yoctoproject.org/show_bug.cgi?id=14952
Help avoid contention by adding a check to ensure targets are at least 60s old when attempting to move them into a trash directory. Signed-off-by: Trevor Gamblin <[email protected]> --- janitor/clobberdir | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/janitor/clobberdir b/janitor/clobberdir index 16b019e..832173c 100755 --- a/janitor/clobberdir +++ b/janitor/clobberdir @@ -52,8 +52,12 @@ trashdir = utils.getconfig("TRASH_DIR", ourconfig) for x in [clobberdir]: if os.path.exists(x) and os.path.exists(trashdir): if (os.stat(trashdir).st_dev == os.stat(x).st_dev): - trashdest = trashdir + "/" + str(int(time.time())) + '-' + str(random.randrange(100, 100000, 2)) - mkdir(trashdest) - subprocess.check_call(['mv', x, trashdest]) + x_age = time.time() - os.path.getmtime(x) + if x_age > 60: + trashdest = trashdir + "/" + str(int(time.time())) + '-' + str(random.randrange(100, 100000, 2)) + mkdir(trashdest) + subprocess.check_call(['mv', x, trashdest]) + else: + print("Not moving '%s' - age is only %s seconds. There may be another process using it" % (x, str(int(x_age)))) else: subprocess.check_call(['rm', "-rf", x]) -- 2.40.1
-=-=-=-=-=-=-=-=-=-=-=- Links: You receive all messages sent to this group. View/Reply Online (#60216): https://lists.yoctoproject.org/g/yocto/message/60216 Mute This Topic: https://lists.yoctoproject.org/mt/99392420/21656 Group Owner: [email protected] Unsubscribe: https://lists.yoctoproject.org/g/yocto/unsub [[email protected]] -=-=-=-=-=-=-=-=-=-=-=-
