mirror of
https://github.com/jenkinsci/jenkins.git
synced 2026-11-08 01:26:03 +00:00
Update center will create backup files to make it easier for manual roll back of botched upgrades.
git-svn-id: https://hudson.dev.java.net/svn/hudson/trunk/hudson/main@21980 71c3de6d-444a-0410-be80-ed276b4c234a
This commit is contained in:
1 parent
66f157955a
commit
25ca3de5fc
2 files changed
+17
-1
No files matched your search
@@ -1044,6 +1044,19 @@ public class Util {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a file name by changing its extension.
|
||||
*
|
||||
* @param ext
|
||||
* For example, ".zip"
|
||||
*/
|
||||
public static File changeExtension(File dst, String ext) {
|
||||
String p = dst.getPath();
|
||||
int pos = p.lastIndexOf('.');
|
||||
if (pos<0) return new File(p+ext);
|
||||
else return new File(p.substring(0,pos)+ext);
|
||||
}
|
||||
|
||||
public static final FastDateFormat XS_DATETIME_FORMATTER = FastDateFormat.getInstance("yyyy-MM-dd'T'HH:mm:ss'Z'",new SimpleTimeZone(0,"GMT"));
|
||||
|
||||
// Note: RFC822 dates must not be localized!
|
||||
|
||||
@@ -835,7 +835,10 @@ public class UpdateCenter extends AbstractModelObject {
|
||||
* the old file with the new file.
|
||||
*/
|
||||
protected void replace(File dst, File src) throws IOException {
|
||||
dst.delete();
|
||||
File bak = Util.changeExtension(dst,".bak");
|
||||
bak.delete();
|
||||
dst.renameTo(bak);
|
||||
dst.delete(); // any failure up to here is no big deal
|
||||
if(!src.renameTo(dst)) {
|
||||
throw new IOException("Failed to rename "+src+" to "+dst);
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user