Class DatasetDownloadUtils
java.lang.Object
gaiasky.util.datadesc.DatasetDownloadUtils
Utilities to fetch and uncompress datasets.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final ReentrantLockReentrant lock to synchronize the latter part of the dataset download process: checksum, extraction, and dataset enable+UI update.static final String -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic voidcleanupTempFile(String file) Remove a single file in the temp directory.static voidWe should never need to call this, as the mainGaiaSky.dispose()method already cleans up the temp directory.static voidcleanupTempFiles(boolean dataDownloads, boolean dataDescriptor) static voidcopyInstallFields(Dataset target, Dataset source) Copies the installation-related fields of the source dataset into the target dataset, leaving identity fields (key, file URL) untouched.static DatasetdatasetFromDescriptor(Path descriptorFile) Builds aDatasetfrom adataset.jsondescriptor file.static voiddecompress(String in, File out, Dataset dataset) static voiddeleteFile(Path p) static longReturns the file size.static longfileSizeGZUncompressed(String inputFilePath) Returns the GZ uncompressed size.static DatasetfindLocalDataset(Path dataLocation, String key, String name) Finds a locally installed dataset matching the given key or name, by scanning thedataset.jsondescriptors in the data location.findNewDescriptors(Set<Path> before, Path dataLocation) Findsdataset.jsondescriptors in the given data location that are not contained in the given snapshot.static booleanstatic booleanlocalDatasets(Path dataLocation) Scans the given data location fordataset.jsondescriptors and builds the datasets they describe.snapshotDescriptors(Path dataLocation) Snapshots the paths of alldataset.jsondescriptors currently present in the given data location (at depth 2, i.e.
-
Field Details
-
mirrorKeyword
- See Also:
-
EXTRACTION_LOCK
Reentrant lock to synchronize the latter part of the dataset download process: checksum, extraction, and dataset enable+UI update.
-
-
Constructor Details
-
DatasetDownloadUtils
public DatasetDownloadUtils()
-
-
Method Details
-
fileSize
Returns the file size.- Parameters:
inputFilePath- A file.- Returns:
- The size in bytes.
-
fileSizeGZUncompressed
Returns the GZ uncompressed size.- Parameters:
inputFilePath- A gzipped file.- Returns:
- The uncompressed size in bytes.
- Throws:
IOException- If the file failed to read.
-
cleanupTempFiles
public static void cleanupTempFiles()We should never need to call this, as the mainGaiaSky.dispose()method already cleans up the temp directory. This way, we allow download resumes within the same session. -
cleanupTempFile
Remove a single file in the temp directory.- Parameters:
file- The file to remove.
-
cleanupTempFiles
public static void cleanupTempFiles(boolean dataDownloads, boolean dataDescriptor) -
deleteFile
-
decompress
-
snapshotDescriptors
Snapshots the paths of alldataset.jsondescriptors currently present in the given data location (at depth 2, i.e.<data location>/<dataset dir>/dataset.json). Used to detect descriptors added by an extraction, regardless of the directory names inside the archive.- Parameters:
dataLocation- The data location directory.- Returns:
- The set of existing descriptor paths.
-
findNewDescriptors
Findsdataset.jsondescriptors in the given data location that are not contained in the given snapshot. Meant to be called right after an extraction, with the snapshot taken right before.- Parameters:
before- The snapshot taken before the extraction.dataLocation- The data location directory.- Returns:
- The list of new descriptor paths, possibly empty.
-
datasetFromDescriptor
-
copyInstallFields
Copies the installation-related fields of the source dataset into the target dataset, leaving identity fields (key, file URL) untouched. Used to update a URL-derived stub dataset in place once the real descriptor has been resolved after extraction.- Parameters:
target- The dataset to update.source- The dataset to copy the fields from.
-
localDatasets
-
findLocalDataset
Finds a locally installed dataset matching the given key or name, by scanning thedataset.jsondescriptors in the data location.- Parameters:
dataLocation- The data location directory.key- The dataset key. May be null.name- The dataset name. May be null.- Returns:
- The matching dataset, or null if none is found.
-
isEnabled
-
isPathIn
-