// Path: src/main/java/com/yet/dsync/dto/DropboxFileData.java
// @Data
// @Builder(toBuilder = true)
// public final class DropboxFileData {
// 
//     private final DropboxChangeType changeType;
// 
//     private final String pathDisplay;
// 
//     private final String pathLower;
// 
//     private final String id;
// 
//     private final String rev;
// 
//     private final Long size;
// 
//     private final LocalDateTime serverModified;
// 
//     private final LocalDateTime clientModified;
// 
//     public boolean isFile() {
//         return rev != null;
//     }
// 
//     public boolean isDirectory() {
//         return id != null && rev == null;
//     }
// 
//     @Override
//     public String toString() {
//         String str = this.getClass().getSimpleName() + " [" + changeType + " " + pathDisplay;
// 
//         if (DropboxChangeType.FOLDER == changeType) {
//             str += ", id: " + id;
//         } else if (DropboxChangeType.FILE == changeType) {
//             str += ", id: " + id + ", rev: " + rev + ", size: " + size
//                     + ", client: " + clientModified + ", server: " + serverModified;
//         }
// 
//         str += "]";
//         return str;
//     }
// }
// 
// Path: src/main/java/com/yet/dsync/exception/DSyncClientException.java
// public class DSyncClientException extends RuntimeException {
// 
//     private static final long serialVersionUID = 1L;
// 
//     public DSyncClientException(final String message) {
//         super(message);
//     }
// 
//     public DSyncClientException(final Throwable cause) {
//         super(cause);
//     }
// 
//     public DSyncClientException(final String message, final Throwable cause) {
//         super(message, cause);
//     }
// 
//     public DSyncClientException(final String message, final Throwable cause,
//                                 final boolean enableSuppression, final boolean writableStackTrace) {
//         super(message, cause, enableSuppression, writableStackTrace);
//     }
// 
// }


import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;
import com.yet.dsync.dto.DropboxFileData;
import com.yet.dsync.exception.DSyncClientException;
import lombok.SneakyThrows;
import java.math.BigDecimal;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Types;
import java.time.Instant;
import java.time.LocalDateTime;
import java.time.ZoneId;
import java.util.Collection;
import java.util.LinkedList;
import java.util.Set;

            }
        } finally {
            syncLock.unlock();
        }
    }

    @SneakyThrows
    private void fillInsertStatement(final DropboxFileData fileData) {
        insertStatement.setString(COL_ID, fileData.getId());
        insertStatement.setString(COL_PATH, fileData.getPathDisplay());
        insertStatement.setString(COL_PATH_LOWER, fileData.getPathLower());
        insertStatement.setBoolean(COL_LOADED, false);
        setStatementParams(insertStatement, COL_REV, fileData.getRev(), Types.VARCHAR);
        setStatementParams(insertStatement, COL_SIZE, fileData.getSize(), Types.BIGINT);
        setStatementParams(insertStatement, COL_SRVDATE,
            dateTimeToLong(fileData.getServerModified()), Types.BIGINT);
        setStatementParams(insertStatement, COL_CLIDATE,
            dateTimeToLong(fileData.getClientModified()), Types.BIGINT);
    }

    @SneakyThrows
    public void write(final Set<DropboxFileData> fileDataSet) {
        syncLock.lock();
        try {
            fileDataSet.forEach(fileData -> {

                try {
                    fillInsertStatement(fileData);
                    insertStatement.addBatch();
                } catch (final SQLException ex) {

// Path: src/main/java/com/yet/dsync/dto/DropboxFileData.java
// @Data
// @Builder(toBuilder = true)
// public final class DropboxFileData {
// 
//     private final DropboxChangeType changeType;
// 
//     private final String pathDisplay;
// 
//     private final String pathLower;
// 
//     private final String id;
// 
//     private final String rev;
// 
//     private final Long size;
// 
//     private final LocalDateTime serverModified;
// 
//     private final LocalDateTime clientModified;
// 
//     public boolean isFile() {
//         return rev != null;
//     }
// 
//     public boolean isDirectory() {
//         return id != null && rev == null;
//     }
// 
//     @Override
//     public String toString() {
//         String str = this.getClass().getSimpleName() + " [" + changeType + " " + pathDisplay;
// 
//         if (DropboxChangeType.FOLDER == changeType) {
//             str += ", id: " + id;
//         } else if (DropboxChangeType.FILE == changeType) {
//             str += ", id: " + id + ", rev: " + rev + ", size: " + size
//                     + ", client: " + clientModified + ", server: " + serverModified;
//         }
// 
//         str += "]";
//         return str;
//     }
// }
// 
// Path: src/main/java/com/yet/dsync/exception/DSyncClientException.java
// public class DSyncClientException extends RuntimeException {
// 
//     private static final long serialVersionUID = 1L;
// 
//     public DSyncClientException(final String message) {
//         super(message);
//     }
// 
//     public DSyncClientException(final Throwable cause) {
//         super(cause);
//     }
// 
//     public DSyncClientException(final String message, final Throwable cause) {
//         super(message, cause);
//     }
// 
//     public DSyncClientException(final String message, final Throwable cause,
//                                 final boolean enableSuppression, final boolean writableStackTrace) {
//         super(message, cause, enableSuppression, writableStackTrace);
//     }
// 
// }


// Path: src/main/java/com/yet/dsync/dao/MetadataDao.java
import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;
import com.yet.dsync.dto.DropboxFileData;
import com.yet.dsync.exception.DSyncClientException;
import lombok.SneakyThrows;
import java.math.BigDecimal;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Types;
import java.time.Instant;
import java.time.LocalDateTime;
import java.time.ZoneId;
import java.util.Collection;
import java.util.LinkedList;
import java.util.Set;

            }
        } finally {
            syncLock.unlock();
        }
    }

    @SneakyThrows
    private void fillInsertStatement(final DropboxFileData fileData) {
        insertStatement.setString(COL_ID, fileData.getId());
        insertStatement.setString(COL_PATH, fileData.getPathDisplay());
        insertStatement.setString(COL_PATH_LOWER, fileData.getPathLower());
        insertStatement.setBoolean(COL_LOADED, false);
        setStatementParams(insertStatement, COL_REV, fileData.getRev(), Types.VARCHAR);
        setStatementParams(insertStatement, COL_SIZE, fileData.getSize(), Types.BIGINT);
        setStatementParams(insertStatement, COL_SRVDATE,
            dateTimeToLong(fileData.getServerModified()), Types.BIGINT);
        setStatementParams(insertStatement, COL_CLIDATE,
            dateTimeToLong(fileData.getClientModified()), Types.BIGINT);
    }

    @SneakyThrows
    public void write(final Set<DropboxFileData> fileDataSet) {
        syncLock.lock();
        try {
            fileDataSet.forEach(fileData -> {

                try {
                    fillInsertStatement(fileData);
                    insertStatement.addBatch();
                } catch (final SQLException ex) {

                    throw new DSyncClientException(ex);
