1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-08-06 07:45:50 +02:00

[351993] [dstore] not able to connect to server if .eclipse folder not available

This commit is contained in:
David McKnight 2011-07-13 17:13:32 +00:00
parent c1a759e556
commit 10942be646
2 changed files with 65 additions and 29 deletions

View file

@ -37,6 +37,7 @@
* David McKnight (IBM) - [336257] [dstore] leading file.searator in DSTORE_LOG_DIRECTORY not handled
* David McKnight (IBM) - [283613] [dstore] Create a Constants File for all System Properties we support
* David McKnight (IBM) - [340080] [dstore] empty string should not be allowed as a DataElement ID
* David McKnight (IBM) - [351993] [dstore] not able to connect to server if .eclipse folder not available
*******************************************************************************/
package org.eclipse.dstore.core.model;
@ -3692,7 +3693,7 @@ public final class DataStore
if (SystemServiceManager.getInstance().getSystemService() == null){
String logDir = getUserPreferencesDirectory();
_traceFileHandle = new File(logDir, ".dstoreTrace"); //$NON-NLS-1$
if (_traceFileHandle.canWrite()){
try
{
_traceFile = new RandomAccessFile(_traceFileHandle, "rw"); //$NON-NLS-1$
@ -3700,6 +3701,12 @@ public final class DataStore
}
catch (IOException e)
{
// turn tracing off if there's a problem
_tracingOn = false;
}
}
else {
_tracingOn = false;
}
}
}
@ -3733,7 +3740,7 @@ public final class DataStore
{
String logDir = getUserPreferencesDirectory();
_memLoggingFileHandle = new File(logDir, ".dstoreMemLogging"); //$NON-NLS-1$
if (_memLoggingFileHandle.canWrite()){
try
{
_memLogFile = new RandomAccessFile(_memLoggingFileHandle, "rw"); //$NON-NLS-1$
@ -3741,6 +3748,12 @@ public final class DataStore
}
catch (IOException e)
{
// turn mem logging off if there's a problem
_memLoggingOn = false;
}
}
else {
_memLoggingOn = false;
}
}
_deRemover = new DataElementRemover(this);
@ -4374,8 +4387,9 @@ public final class DataStore
String cacheDirectory = getCacheDirectory();
File cacheJar = new File(cacheDirectory + REMOTE_CLASS_CACHE_JARFILE_NAME + JARFILE_EXTENSION);
File nextCacheJar = new File(cacheDirectory + REMOTE_CLASS_CACHE_JARFILE_NAME + "_next" + JARFILE_EXTENSION); //$NON-NLS-1$
if (nextCacheJar.exists()) nextCacheJar.renameTo(cacheJar);
if (!cacheJar.exists())
if (nextCacheJar.exists())
nextCacheJar.renameTo(cacheJar);
if (!cacheJar.exists() && cacheJar.canWrite())
{
try
{
@ -4383,6 +4397,8 @@ public final class DataStore
cacheOut.putNextEntry(new JarEntry("/")); //$NON-NLS-1$
cacheOut.closeEntry();
cacheOut.close();
_cacheJar = cacheJar;
}
catch (IOException e)
{
@ -4391,11 +4407,11 @@ public final class DataStore
return;
}
}
_cacheJar = cacheJar;
if (!_cacheJar.canWrite()){ // can't write this..don't bother with cache
else {
_cacheJar = null;
}
}
protected String getCacheDirectory()
@ -4529,6 +4545,7 @@ public final class DataStore
{
if (_tracingOn) {
_traceFileHandle = new File(logDir, ".dstoreTrace"); //$NON-NLS-1$
if (_traceFileHandle.canWrite()){
try
{
_traceFile = new RandomAccessFile(_traceFileHandle, "rw"); //$NON-NLS-1$
@ -4536,6 +4553,12 @@ public final class DataStore
}
catch (IOException e)
{
// turn tracing off if there's a problem
_tracingOn = false;
}
}
else {
_tracingOn = false;
}
}
}

View file

@ -23,6 +23,7 @@
* David McKnight (IBM) - [305272] [dstore][multithread] log close in ServerLogger
* David McKnight (IBM) - [283613] [dstore] Create a Constants File for all System Properties we support
* Noriaki Takatsu (IBM) - [341578] [dstore] ServerLogger is looped when IOError happens
* David McKnight (IBM) - [351993] [dstore] not able to connect to server if .eclipse folder not available
********************************************************************************/
package org.eclipse.dstore.core.server;
@ -91,6 +92,8 @@ public class ServerLogger implements IServerLogger
} catch (Exception e) {
// Just use logging defaults: log_level = 0, log to file
//e.printStackTrace();
logToFile = false;
_logFileStream = new PrintWriter(System.out);
}
}
@ -101,10 +104,20 @@ public class ServerLogger implements IServerLogger
if (logToFile) {
try {
File _logFile = getLogFile("rsecomm"); //$NON-NLS-1$
if (_logFile != null && _logFile.canWrite()){
_logFileStream = new PrintWriter(new FileOutputStream(_logFile));
}
else {
log_level = 0;
logToFile = false;
_logFileStream = new PrintWriter(System.out);
}
} catch (IOException e) {
System.out.println("Error opening log file " + logPathName + "rsecomm.log"); //$NON-NLS-1$ //$NON-NLS-2$
log_level = 0;
logToFile = false;
_logFileStream = new PrintWriter(System.out);
}
}
}