Search in sources :

Example 1 with MCRFileAttributes

use of org.mycore.datamodel.niofs.MCRFileAttributes in project mycore by MyCoRe-Org.

the class MCRUploadHandlerIFS method acceptFile.

@Override
public boolean acceptFile(String path, String checksum, long length) throws Exception {
    LOGGER.debug("incoming acceptFile request: {} {} {} bytes", path, checksum, length);
    boolean shouldAcceptFile = true;
    if (rootDir != null) {
        MCRPath child = MCRPath.toMCRPath(rootDir.resolve(path));
        if (Files.isRegularFile(child)) {
            @SuppressWarnings("rawtypes") MCRFileAttributes attrs = Files.readAttributes(child, MCRFileAttributes.class);
            shouldAcceptFile = attrs.size() != length || !(checksum.equals(attrs.md5sum()) && child.getFileSystem().verifies(child, attrs));
        }
    }
    LOGGER.debug("Should the client send this file? {}", shouldAcceptFile);
    return shouldAcceptFile;
}
Also used : MCRFileAttributes(org.mycore.datamodel.niofs.MCRFileAttributes) MCRPath(org.mycore.datamodel.niofs.MCRPath)

Aggregations

MCRFileAttributes (org.mycore.datamodel.niofs.MCRFileAttributes)1 MCRPath (org.mycore.datamodel.niofs.MCRPath)1