mirror of https://github.com/micromata/borgbackup-butler.git

Kai Reinhard
28.55.2018 60f6fbc31679a112958db1fbecc62e8195b127f6
borgbutler-core/src/main/java/de/micromata/borgbutler/jobs/JobQueue.java
@@ -28,17 +28,19 @@
     * Appends the job if not alread in the queue. Starts the execution if no execution thread is already running.
     *
     * @param job
     * @return The given job (if it's not already running or queued), otherwise the already running or queued job.
     */
    public void append(AbstractJob job) {
    public AbstractJob append(AbstractJob job) {
        synchronized (queue) {
            for (AbstractJob queuedJob : queue) {
                if (Objects.equals(queuedJob.getId(), job.getId())) {
                    log.info("Job is already in the queue, don't run twice (OK): " + job.getId());
                    return;
                    return queuedJob;
                }
            }
            queue.add(job.setStatus(AbstractJob.Status.QUEUED));
            job.setFuture(executorService.submit(new CallableTask(job)));
            return job;
        }
    }