def handle_repository_update(repository): repository_path = REPOSITORY_BASE_PATH % repository lock_file_path = UPDATE_LOCK_FILE % repository_path # this is not exactly safe against race-conditions but should be good enough if exists(lock_file_path): # if there is currently an update process running, simply mark the repository to be updated # again later, a cronjob will pick it update_notify_path = UPDATE_NOTIFY_FILE % repository_path update_notify = open(update_notify_path, 'w') update_notify.write('1') update_notify.close() logger.warn(u'Not updating repository %s because it is locked, leaving a notify', repository) else: lock_file = open(lock_file_path, 'w') update_repository(repository, repository_path, logger) # remove lockfile lock_file.close() unlink(lock_file_path)
def handle_repository_update(repository): repository_path = join(REPOSITORY_BASE_PATH, repository) lock_file_path = UPDATE_LOCK_FILE % repository_path update_notify_path = UPDATE_NOTIFY_FILE % repository_path # this is not exactly safe against race-conditions but should be good enough if exists(lock_file_path): return if exists(update_notify_path): update_notify_file = open(update_notify_path, 'r+') need_update = update_notify_file.read() == '1' if need_update: lock_file = open(lock_file_path, 'w') update_repository(repository, repository_path, logger, run_as='www-data') # remove lockfile lock_file.close() unlink(lock_file_path) # unmark update notify update_notify_file.truncate(0) update_notify_file.close()
def handle_repository_update(repository): repository_path = REPOSITORY_BASE_PATH % repository lock_file_path = UPDATE_LOCK_FILE % repository_path # this is not exactly safe against race-conditions but should be good enough if exists(lock_file_path): # if there is currently an update process running, simply mark the repository to be updated # again later, a cronjob will pick it update_notify_path = UPDATE_NOTIFY_FILE % repository_path update_notify = open(update_notify_path, 'w') update_notify.write('1') update_notify.close() logger.warn( u'Not updating repository %s because it is locked, leaving a notify', repository) else: lock_file = open(lock_file_path, 'w') update_repository(repository, repository_path, logger) # remove lockfile lock_file.close() unlink(lock_file_path)