use of com.gitblit.models.FilestoreModel in project gitblit by gitblit.
the class FilestoreManager method downloadBlob.
@Override
public FilestoreModel.Status downloadBlob(String oid, UserModel user, RepositoryModel repo, OutputStream streamOut) {
//Access control and object logic
Status status = canGetObject(oid, user, repo);
if (status != Status.Available) {
return status;
}
FilestoreModel item = fileCache.get(oid);
if (streamOut != null) {
try (FileInputStream streamIn = new FileInputStream(getStoragePath(oid))) {
IOUtils.copyLarge(streamIn, streamOut);
streamOut.flush();
streamIn.close();
} catch (EOFException e) {
logger.error(MessageFormat.format("Client aborted connection for {0}", oid), e);
return Status.Error_Unexpected_Stream_End;
} catch (Exception e) {
logger.error(MessageFormat.format("Failed to download blob {0}", oid), e);
return Status.Error_Unknown;
}
}
return item.getStatus();
}
use of com.gitblit.models.FilestoreModel in project gitblit by gitblit.
the class FilestoreManager method getFilestoreUsedByteCount.
@Override
public long getFilestoreUsedByteCount() {
Iterator<FilestoreModel> iterator = fileCache.values().iterator();
long total = 0;
while (iterator.hasNext()) {
FilestoreModel item = iterator.next();
if (item.getStatus() == Status.Available) {
total += item.getSize();
}
}
return total;
}
Aggregations