// 
// Decompiled by Procyon v0.6.0
// 

package io.sentry;

import java.io.File;
import io.sentry.cache.IEnvelopeCache;
import io.sentry.cache.EnvelopeCache;
import org.jetbrains.annotations.NotNull;

final class MovePreviousSession implements Runnable
{
    @NotNull
    private final SentryOptions options;
    
    MovePreviousSession(@NotNull final SentryOptions options) {
        this.options = options;
    }
    
    @Override
    public void run() {
        final String cacheDirPath = this.options.getCacheDirPath();
        if (cacheDirPath == null) {
            this.options.getLogger().log(SentryLevel.INFO, "Cache dir is not set, not moving the previous session.", new Object[0]);
            return;
        }
        if (!this.options.isEnableAutoSessionTracking()) {
            this.options.getLogger().log(SentryLevel.DEBUG, "Session tracking is disabled, bailing from previous session mover.", new Object[0]);
            return;
        }
        final IEnvelopeCache cache = this.options.getEnvelopeDiskCache();
        if (cache instanceof EnvelopeCache) {
            final File currentSessionFile = EnvelopeCache.getCurrentSessionFile(cacheDirPath);
            final File previousSessionFile = EnvelopeCache.getPreviousSessionFile(cacheDirPath);
            ((EnvelopeCache)cache).movePreviousSession(currentSessionFile, previousSessionFile);
            ((EnvelopeCache)cache).flushPreviousSession();
        }
    }
}
