use of org.sonarsource.sonarlint.core.container.connected.update.ProjectListDownloader in project sonarlint-core by SonarSource.
the class GlobalStorageUpdateExecutor method update.
public void update(ServerApiHelper serverApiHelper, ProgressMonitor progress) {
Path temp;
try {
temp = Files.createTempDirectory("sonarlint-global-storage");
} catch (IOException e) {
throw new IllegalStateException("Unable to create temp directory", e);
}
try {
StorageFolder storageFolder = new StorageFolder.Default(temp);
var serverInfoStore = new ServerInfoStore(storageFolder);
var serverProjectsStore = new ServerProjectsStore(storageFolder);
var storageStatusStore = new StorageStatusStore(storageFolder);
progress.setProgressAndCheckCancel("Checking server version and status", 0.1f);
var serverStatus = new ServerVersionAndStatusChecker(serverApiHelper).checkVersionAndStatus();
serverInfoStore.store(serverStatus);
progress.setProgressAndCheckCancel("Fetching list of projects", 0.8f);
var projectListDownloader = new ProjectListDownloader(serverApiHelper, serverProjectsStore);
projectListDownloader.fetch(progress.subProgress(0.8f, 1.0f, "Fetching list of projects"));
progress.setProgressAndCheckCancel("Finalizing...", 1.0f);
progress.executeNonCancelableSection(() -> {
var storageStatus = StorageStatus.newBuilder().setStorageVersion(ProjectStoragePaths.STORAGE_VERSION).setSonarlintCoreVersion(VersionUtils.getLibraryVersion()).setUpdateTimestamp(new Date().getTime()).build();
storageStatusStore.store(storageStatus);
serverStorage.replaceStorageWith(temp);
});
} finally {
org.apache.commons.io.FileUtils.deleteQuietly(temp.toFile());
}
}
Aggregations