1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-08-16 20:55:44 +02:00

[367424] [dstore] upload mechanism should provide backups of files

-ammendment to backup renaming
This commit is contained in:
David McKnight 2012-03-13 20:00:00 +00:00
parent 0455f0b994
commit 58f79d1be1

View file

@ -82,9 +82,9 @@ public class ByteStreamHandler implements IByteStreamHandler
{ {
// need to create directories as well // need to create directories as well
File file = new File(fileName); File file = new File(fileName);
File parent = new File(file.getParent());
if (!file.exists()) if (!file.exists())
{ {
File parent = new File(file.getParent());
parent.mkdirs(); parent.mkdirs();
} }
else else
@ -93,7 +93,10 @@ public class ByteStreamHandler implements IByteStreamHandler
String doBackups = System.getProperty("backupfiles"); //$NON-NLS-1$ String doBackups = System.getProperty("backupfiles"); //$NON-NLS-1$
if (doBackups == null || doBackups.equals("true")){ //$NON-NLS-1$ if (doBackups == null || doBackups.equals("true")){ //$NON-NLS-1$
// backup the file first // backup the file first
file.renameTo(new File('.'+fileName+"~")); //$NON-NLS-1$ String n = file.getName();
File backupFile = new File(parent, '.' + n + '~');
_dataStore.trace("Backing up as "+backupFile.getAbsolutePath()); //$NON-NLS-1$
file.renameTo(backupFile);
} }
} }