vieiro closed pull request #329: [NETBEANS-210] Setting tmp directory
URL: https://github.com/apache/incubator-netbeans/pull/329
This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:
As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):
diff --git
a/maven.indexer/src/org/netbeans/modules/maven/indexer/NexusRepositoryIndexerImpl.java
b/maven.indexer/src/org/netbeans/modules/maven/indexer/NexusRepositoryIndexerImpl.java
index ff611a7da..98ecb1c8f 100644
---
a/maven.indexer/src/org/netbeans/modules/maven/indexer/NexusRepositoryIndexerImpl.java
+++
b/maven.indexer/src/org/netbeans/modules/maven/indexer/NexusRepositoryIndexerImpl.java
@@ -451,9 +451,11 @@ private void unloadIndexingContext(final String repo)
throws IOException {
}
@Messages({"# {0} - folder path",
- "MSG_NoSpace=There is not enough space in your temp folder to
download and unpack the index for ''{0}''.",
+ "# {1} - repository name",
+ "MSG_NoSpace=There is not enough space in {0} to download and
unpack the index for ''{1}''.",
"# {0} - folder path",
- "MSG_SeemsNoSpace=It seems that there is not enough space in
your temp folder to download and unpack the index for ''{0}''."})
+ "# {1} - repository name",
+ "MSG_SeemsNoSpace=It seems that there is not enough space in
{0} to download and unpack the index for ''{1}''."})
private void indexLoadedRepo(final RepositoryInfo repo, boolean
updateLocal) throws IOException {
Mutex mutex = getRepoMutex(repo);
assert mutex.isWriteAccess();
@@ -554,28 +556,27 @@ private void indexLoadedRepo(final RepositoryInfo repo,
boolean updateLocal) thr
if(e.getCause() instanceof ResourceDoesNotExistException) {
fireChange(repo, () -> repo.fireNoIndex());
}
-
+ File tmpFolder = Places.getCacheDirectory();
// see also issue #250365
String noSpaceLeftMsg = null;
if(e.getMessage().contains("No space left on device")) {
- noSpaceLeftMsg = Bundle.MSG_NoSpace(repo.getName());
+ noSpaceLeftMsg =
Bundle.MSG_NoSpace(tmpFolder.getAbsolutePath(), repo.getName());
}
long downloaded = listener != null ? listener.getUnits() * 1024 :
-1;
long usableSpace = -1;
- File tmpFolder = new File(System.getProperty("java.io.tmpdir"));
try {
FileStore store = Files.getFileStore(tmpFolder.toPath());
usableSpace = store.getUsableSpace();
} catch (IOException ex) {
Exceptions.printStackTrace(ex);
}
- LOGGER.log(Level.INFO, "Downloaded maven index file has size {0}
(zipped). The usable space in {1} (java.io.tmpdir) is {2}.", new
Object[]{downloaded, tmpFolder, usableSpace});
+ LOGGER.log(Level.INFO, "Downloaded maven index file has size {0}
(zipped). The usable space in {1} is {2}.", new Object[]{downloaded, tmpFolder,
usableSpace});
// still might be a problem with a too small tmp,
// let's try to figure out ...
if(noSpaceLeftMsg == null && downloaded > -1 && downloaded * 15 >
usableSpace) {
- noSpaceLeftMsg = Bundle.MSG_SeemsNoSpace(repo.getName());
+ noSpaceLeftMsg =
Bundle.MSG_SeemsNoSpace(tmpFolder.getAbsolutePath(), repo.getName());
}
if(noSpaceLeftMsg != null) {
@@ -695,14 +696,13 @@ private void scan( final IndexingContext context, final
String fromPath, final A
throw new IOException( "Repository directory " +
repositoryDirectory + " does not exist" );
}
- // always use temporary context when reindexing
- //TODO select a location within netbeans cache directory not
File.createTempFile
- final File tmpFile = File.createTempFile( context.getId() + "-tmp", ""
);
- final File tmpDir = new File( tmpFile.getParentFile(),
tmpFile.getName() + ".dir" );
+ // always use cache directory when reindexing
+ final File tmpDir = new File(Places.getCacheDirectory(), "tmp-" +
context.getRepositoryId());
if ( !tmpDir.mkdirs() )
{
throw new IOException( "Cannot create temporary directory: " +
tmpDir );
}
+ final File tmpFile = new File(tmpDir, context.getId() + "-tmp");
IndexingContext tmpContext = null;
try
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists