package com.kospo.talk.config.utils;

import lombok.Getter;

import java.io.FileNotFoundException;
import java.time.LocalDateTime;
import java.util.Date;
import java.util.HashMap;

public class MultipleUpload {
    @Getter
    private long fileSize;
    @Getter
    private long bytesReceived;
    @Getter
    private LocalDateTime insDate;
    private HashMap<Integer, FileState> uploadStates = new HashMap<>();

    public MultipleUpload(long fileSize, LocalDateTime insDate) {
        this.fileSize = fileSize;
        this.insDate = insDate;
    }

    public void setBytesReceived(int fileSize) {
        bytesReceived += fileSize;
    };

    public void setUploadState(Integer sort, String vnm) {
        try {
            FileState state = new FileState(vnm);
            uploadStates.put(sort, state);
        } catch (FileNotFoundException e) {
            throw new RuntimeException(e);
        }
    }

    public FileState getUploadState(int sort) {
        return uploadStates.get(sort);
    }
}
