Called when a file (or directory) is modified.

def on_modified(self, event, dry_run=False, remove_uploaded=True):
        'Called when a file (or directory) is modified. '
        super(ArchiveEventHandler, self).on_modified(event)
        src_path = event.src_path
        if event.is_directory:
            if not platform.is_darwin():
                log.info("event is a directory, safe to ignore")
                return
            # OSX is behaving erratically and we need to paper over it.
            # the OS only reports every other file event,
            # but always fires off a directory event when a file has changed. (OSX 10.9 tested)
            # so we need to find the actual file changed and then go on from there
            files = [event.src_path+"/"+f for f in os.listdir(event.src_path)]
            try:
                src_path = max(files, key=os.path.getmtime)
            except (OSError, ValueError) as e: # broken symlink or directory empty
                return
        log.info('Modified file detectd: %s', src_path)
        #
        # we're receiving events at least two times: on file open and on file close.
        # OSes might report even more
        # we're only interested in files that are closed (finished), so we try to
        # open it. if it is locked, we can infer that someone is still writing to it.
        # this works on platforms: windows, ... ?
        # TODO: investigate http://stackoverflow.com/a/3876461 for POSIX support
        try:
            open(src_path)   # win exclusively
            os.open(src_path, os.O_EXLOCK) # osx exclusively
        except IOError: # file is not finished
            log.info('File is not finished')
            return
        except AttributeError: # no suuport for O_EXLOCK (only BSD)
            pass
        return self._new(src_path, dry_run, remove_uploaded)