Search in sources :

Example 1 with LastChange

use of com.gitblit.utils.JGitUtils.LastChange in project gitblit by gitblit.

the class RepositoryManager method updateLastChangeFields.

/**
	 * Updates the last changed fields and optionally calculates the size of the
	 * repository.  Gitblit caches the repository sizes to reduce the performance
	 * penalty of recursive calculation. The cache is updated if the repository
	 * has been changed since the last calculation.
	 *
	 * @param model
	 * @return size in bytes of the repository
	 */
@Override
public long updateLastChangeFields(Repository r, RepositoryModel model) {
    LastChange lc = JGitUtils.getLastChange(r);
    model.lastChange = lc.when;
    model.lastChangeAuthor = lc.who;
    if (!settings.getBoolean(Keys.web.showRepositorySizes, true) || model.skipSizeCalculation) {
        model.size = null;
        return 0L;
    }
    if (!repositorySizeCache.hasCurrent(model.name, model.lastChange)) {
        File gitDir = r.getDirectory();
        long sz = com.gitblit.utils.FileUtils.folderSize(gitDir);
        repositorySizeCache.updateObject(model.name, model.lastChange, sz);
    }
    long size = repositorySizeCache.getObject(model.name);
    ByteFormat byteFormat = new ByteFormat();
    model.size = byteFormat.format(size);
    return size;
}
Also used : ByteFormat(com.gitblit.utils.ByteFormat) LastChange(com.gitblit.utils.JGitUtils.LastChange) File(java.io.File)

Aggregations

ByteFormat (com.gitblit.utils.ByteFormat)1 LastChange (com.gitblit.utils.JGitUtils.LastChange)1 File (java.io.File)1