mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-23 00:45:28 +02:00
[367424] [dstore] upload mechanism should provide backups of files
This commit is contained in:
parent
0f73384cd4
commit
b9b1c246f5
1 changed files with 11 additions and 2 deletions
|
@ -1,5 +1,5 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2002, 2009 IBM Corporation and others.
|
* Copyright (c) 2002, 2011 IBM Corporation and others.
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
|
@ -14,6 +14,7 @@
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* David McKnight (IBM) [224906] [dstore] changes for getting properties and doing exit due to single-process capability
|
* David McKnight (IBM) [224906] [dstore] changes for getting properties and doing exit due to single-process capability
|
||||||
* David McKnight (IBM) [281712] [dstore] Warning message is needed when disk is full
|
* David McKnight (IBM) [281712] [dstore] Warning message is needed when disk is full
|
||||||
|
* David McKnight (IBM) [367424] [dstore] upload mechanism should provide backups of files
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
|
|
||||||
package org.eclipse.dstore.core.model;
|
package org.eclipse.dstore.core.model;
|
||||||
|
@ -22,6 +23,8 @@ import java.io.File;
|
||||||
import java.io.FileOutputStream;
|
import java.io.FileOutputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
|
import org.eclipse.dstore.internal.core.model.IDataStoreSystemProperties;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>
|
* <p>
|
||||||
* The ByteStreamHandler class is used to abstract file read and write operations
|
* The ByteStreamHandler class is used to abstract file read and write operations
|
||||||
|
@ -86,6 +89,12 @@ public class ByteStreamHandler implements IByteStreamHandler
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
// backup file on upload by default
|
||||||
|
String doBackups = System.getProperty("backupfiles"); //$NON-NLS-1$
|
||||||
|
if (doBackups == null || doBackups.equals("true")){ //$NON-NLS-1$
|
||||||
|
// backup the file first
|
||||||
|
file.renameTo(new File(fileName+"~")); //$NON-NLS-1$
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
File newFile = new File(fileName);
|
File newFile = new File(fileName);
|
||||||
|
|
Loading…
Add table
Reference in a new issue