if(!config.isNonSharing()){
metadata=this.getMetadata(path);
try {
FileStats fs = metadata.getStats();
fs.setBlocks((int) ((size + 511L) / 512L));
fs.setSize(size);
daS.truncData(metadata.getId_path(), (int)size, metadata.getKey(), metadata.getStats().getDataHash(), false, metadata.getStats().isPending());
NodeMetadata node = new NodeMetadata(metadata.getNodeType(), metadata.getParent(), metadata.getName(), fs, metadata.getId_path(), metadata.getKey(), metadata.getC_r(), metadata.getC_w());
if(metadata.getStats().isPrivate()){
namespace.updateMetadata(path, node);
}else{
long time = System.currentTimeMillis();
directoryService.updateMetadata(path, node);
Statistics.incUpdateMeta(System.currentTimeMillis() - time);
}
} catch (DirectoryServiceConnectionProblemException e) {
throw new FuseException(e.getMessage()).initErrno(FuseException.ECONNABORTED);
} catch (DirectoryServiceException e) {
throw new FuseException(e.getMessage()).initErrno(FuseException.ECONNABORTED);
}
}else{
try {
long time = System.currentTimeMillis();
metadata = directoryService.getMetadata(path);
Statistics.incGetMeta(System.currentTimeMillis() - time);
FileStats fs = metadata.getStats();
fs.setBlocks((int) ((size + 511L) / 512L));
fs.setSize(size);
daS.truncData(metadata.getId_path(), (int)size, metadata.getKey(), metadata.getStats().getDataHash(), false, metadata.getStats().isPending());
NodeMetadata node = new NodeMetadata(metadata.getNodeType(), metadata.getParent(), metadata.getName(), fs, metadata.getId_path(), metadata.getKey(), metadata.getC_r(), metadata.getC_w());
time = System.currentTimeMillis();
directoryService.updateMetadata(path, node);