jeudi 5 novembre 2015

Delete temporary locked files

At some point of my process i have to delete a specific file, because the file is used as "flag" that something was corrupted (Part of a Backup Logic).

Sometimes the file is locked by a virus scanner or anything else, but this lock is temporary. In any case the specific file has to be deleted, otherwise the next process may be broken. I also thought about creating a second file flag that the first flag is corrupt, but in the end you could create hundreds of flags, so this is not a solution.

I tried to delete the file wihtin a loop and keep waiting for some millis, before trying to fire the next delete command.

    for (int i = 0; i < 10; i++) {
        if (FileUtils.deleteQuietly(file)) {

        try {
        } catch (InterruptedException e) {

  1. Do you see a Utility class out there this scenario is already implemented?
  2. How do you handle create/delete commands if a virus scanner is locking you files?

Aucun commentaire:

Enregistrer un commentaire