def add_watches_to_udf_ancestors(self, volume): """Add a inotify watch to volume's ancestors if it's an UDF.""" # This is a platform dependent operation since there are cases in # which the watches do not have to be added (On windows we do not # have to add them since we have an opened handle.) # finally, check that UDF is ok in disk if not access(volume.path): # if we cannot access the UDF lets return false and do # nothing return defer.succeed(False) return self.monitor.add_watches_to_udf_ancestors(volume)
def add_watches_to_udf_ancestors(self, volume): """Add a inotify watch to volume's ancestors if it's an UDF.""" added_watches = [] def revert_watches(): """Restore the just added watches and unsubscribe volume.""" for path in added_watches: self.eq.rm_watch(path) for ancestor in volume.ancestors: # check that ancestor is still there if not access(ancestor): self.log.info("Tree broken at path: %r", volume.path) revert_watches() defer.returnValue(False) self.log.debug("Adding watch to UDF's ancestor %r", ancestor) really_added = yield self.eq.add_watch(ancestor) # only note it for the revert if the watch was not there before if really_added: added_watches.append(ancestor) # all is ok defer.returnValue(True)