Search in sources :

Example 1 with FileCacheSynchronizer

use of com.google.idea.blaze.base.filecache.FileCacheSynchronizer in project intellij by bazelbuild.

the class JarCache method refresh.

private void refresh(@Nullable BlazeContext context, boolean removeMissingFiles) {
    if (!enabled || traits == null) {
        return;
    }
    // Ensure the cache dir exists
    if (!cacheDir.exists()) {
        if (!cacheDir.mkdirs()) {
            logger.error("Could not create jar cache directory");
            return;
        }
    }
    FileCacheSynchronizer synchronizer = new FileCacheSynchronizer(traits);
    if (!synchronizer.synchronize(context, removeMissingFiles)) {
        logger.warn("Jar Cache synchronization didn't complete");
    }
    if (context != null) {
        try {
            Collection<File> finalCacheFiles = traits.enumerateCacheFiles();
            ImmutableMap<File, Long> cacheFileSizes = FileSizeScanner.readFilesizes(finalCacheFiles);
            Long total = cacheFileSizes.values().stream().mapToLong(x -> x).sum();
            context.output(PrintOutput.log(String.format("Total Jar Cache size: %d kB (%d files)", total / 1024, finalCacheFiles.size())));
        } catch (Exception e) {
            logger.warn("Could not determine cache size", e);
        }
    }
}
Also used : SyncMode(com.google.idea.blaze.base.sync.BlazeSyncParams.SyncMode) BlazeContext(com.google.idea.blaze.base.scope.BlazeContext) ListenableFuture(com.google.common.util.concurrent.ListenableFuture) BlazeLibrary(com.google.idea.blaze.base.model.BlazeLibrary) StandardCopyOption(java.nio.file.StandardCopyOption) ArrayList(java.util.ArrayList) FileCache(com.google.idea.blaze.base.filecache.FileCache) BlazeSyncParams(com.google.idea.blaze.base.sync.BlazeSyncParams) BlazeJarLibrary(com.google.idea.blaze.java.sync.model.BlazeJarLibrary) BlazeProjectData(com.google.idea.blaze.base.model.BlazeProjectData) Future(java.util.concurrent.Future) Lists(com.google.common.collect.Lists) ImmutableList(com.google.common.collect.ImmutableList) BlazeDataStorage(com.google.idea.blaze.base.sync.data.BlazeDataStorage) Map(java.util.Map) Project(com.intellij.openapi.project.Project) BlazeJavaUserSettings(com.google.idea.blaze.java.settings.BlazeJavaUserSettings) FileUtil(com.intellij.openapi.util.io.FileUtil) FileSizeScanner(com.google.idea.blaze.base.io.FileSizeScanner) Logger(com.intellij.openapi.diagnostic.Logger) Nullable(javax.annotation.Nullable) BiMap(com.google.common.collect.BiMap) ArtifactLocation(com.google.idea.blaze.base.ideinfo.ArtifactLocation) ImmutableMap(com.google.common.collect.ImmutableMap) Files(java.nio.file.Files) BlazeLibraryCollector(com.google.idea.blaze.base.sync.libraries.BlazeLibraryCollector) Collection(java.util.Collection) BlazeImportSettingsManager(com.google.idea.blaze.base.settings.BlazeImportSettingsManager) IOException(java.io.IOException) PrintOutput(com.google.idea.blaze.base.scope.output.PrintOutput) Collectors(java.util.stream.Collectors) File(java.io.File) BlazeImportSettings(com.google.idea.blaze.base.settings.BlazeImportSettings) HashBiMap(com.google.common.collect.HashBiMap) List(java.util.List) ServiceManager(com.intellij.openapi.components.ServiceManager) FileCacheSynchronizerTraits(com.google.idea.blaze.base.filecache.FileCacheSynchronizerTraits) Paths(java.nio.file.Paths) ProjectViewSet(com.google.idea.blaze.base.projectview.ProjectViewSet) ApplicationManager(com.intellij.openapi.application.ApplicationManager) Preconditions(com.google.common.base.Preconditions) ArtifactLocationDecoder(com.google.idea.blaze.base.sync.workspace.ArtifactLocationDecoder) ListeningExecutorService(com.google.common.util.concurrent.ListeningExecutorService) FileCacheSynchronizer(com.google.idea.blaze.base.filecache.FileCacheSynchronizer) FileCacheSynchronizer(com.google.idea.blaze.base.filecache.FileCacheSynchronizer) File(java.io.File) IOException(java.io.IOException)

Example 2 with FileCacheSynchronizer

use of com.google.idea.blaze.base.filecache.FileCacheSynchronizer in project intellij by bazelbuild.

the class UnpackedAars method refresh.

private void refresh(@Nullable BlazeContext context, boolean removeMissingFiles) {
    if (!enabled || jarTraits == null || aarTraits == null) {
        return;
    }
    FileOperationProvider fileOpProvider = FileOperationProvider.getInstance();
    // Ensure the cache dir exists
    if (!fileOpProvider.exists(cacheDir)) {
        if (!fileOpProvider.mkdirs(cacheDir)) {
            logger.warn("Could not create unpacked AAR directory: " + cacheDir);
            return;
        }
    }
    FileCacheSynchronizer aarSynchronizer = new FileCacheSynchronizer(aarTraits);
    if (!aarSynchronizer.synchronize(context, removeMissingFiles)) {
        logger.warn("Unpacked AAR synchronization didn't complete");
    }
    FileCacheSynchronizer aarJarSynchronizer = new FileCacheSynchronizer(jarTraits);
    if (!aarJarSynchronizer.synchronize(context, removeMissingFiles)) {
        logger.warn("Unpacked AAR jar synchronization didn't complete");
    }
}
Also used : FileOperationProvider(com.google.idea.blaze.base.io.FileOperationProvider) FileCacheSynchronizer(com.google.idea.blaze.base.filecache.FileCacheSynchronizer)

Aggregations

FileCacheSynchronizer (com.google.idea.blaze.base.filecache.FileCacheSynchronizer)2 Preconditions (com.google.common.base.Preconditions)1 BiMap (com.google.common.collect.BiMap)1 HashBiMap (com.google.common.collect.HashBiMap)1 ImmutableList (com.google.common.collect.ImmutableList)1 ImmutableMap (com.google.common.collect.ImmutableMap)1 Lists (com.google.common.collect.Lists)1 ListenableFuture (com.google.common.util.concurrent.ListenableFuture)1 ListeningExecutorService (com.google.common.util.concurrent.ListeningExecutorService)1 FileCache (com.google.idea.blaze.base.filecache.FileCache)1 FileCacheSynchronizerTraits (com.google.idea.blaze.base.filecache.FileCacheSynchronizerTraits)1 ArtifactLocation (com.google.idea.blaze.base.ideinfo.ArtifactLocation)1 FileOperationProvider (com.google.idea.blaze.base.io.FileOperationProvider)1 FileSizeScanner (com.google.idea.blaze.base.io.FileSizeScanner)1 BlazeLibrary (com.google.idea.blaze.base.model.BlazeLibrary)1 BlazeProjectData (com.google.idea.blaze.base.model.BlazeProjectData)1 ProjectViewSet (com.google.idea.blaze.base.projectview.ProjectViewSet)1 BlazeContext (com.google.idea.blaze.base.scope.BlazeContext)1 PrintOutput (com.google.idea.blaze.base.scope.output.PrintOutput)1 BlazeImportSettings (com.google.idea.blaze.base.settings.BlazeImportSettings)1