aboutsummaryrefslogtreecommitdiffstats
path: root/filedistribution/src/main/java/com/yahoo/vespa/filedistribution/LazyTemporaryStorageFileReferenceData.java
blob: 3a2ae8e5218ab9ba8f1e1f3441454f41a9788e39 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.vespa.filedistribution;

import com.yahoo.config.FileReference;

import java.io.File;
import java.io.IOException;
import java.nio.file.Files;

/**
 * File reference data stored in a temporary file that will be deleted when {@link #close()} is called.
 */
public class LazyTemporaryStorageFileReferenceData extends LazyFileReferenceData {

    public LazyTemporaryStorageFileReferenceData(FileReference fileReference, String filename, Type type, File file, CompressionType compressionType) throws IOException {
        super(fileReference, filename, type, file, compressionType);
    }

    public void close() {
        try {
            super.close();
            Files.deleteIfExists(file.toPath());
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }

}