[Bf-blender-cvs] [3416428] master: Recent BLI_rename fix introduced error w/ blend file versioning

Campbell Barton noreply at git.blender.org
Wed Feb 3 07:18:05 CET 2016


Commit: 3416428e0b069faa439e313f0a6c778faa7da6ba
Author: Campbell Barton
Date:   Wed Feb 3 17:06:42 2016 +1100
Branches: master
https://developer.blender.org/rB3416428e0b069faa439e313f0a6c778faa7da6ba

Recent BLI_rename fix introduced error w/ blend file versioning

Rename calls didn't check if the file existed first, so missing file was counted as success and ignored.

===================================================================

M	source/blender/blenloader/intern/writefile.c

===================================================================

diff --git a/source/blender/blenloader/intern/writefile.c b/source/blender/blenloader/intern/writefile.c
index a2802db..e8db2d3 100644
--- a/source/blender/blenloader/intern/writefile.c
+++ b/source/blender/blenloader/intern/writefile.c
@@ -3798,24 +3798,28 @@ static bool do_history(const char *name, ReportList *reports)
 		BKE_report(reports, RPT_ERROR, "Unable to make version backup: filename too short");
 		return 1;
 	}
-		
+
 	while (hisnr > 1) {
 		BLI_snprintf(tempname1, sizeof(tempname1), "%s%d", name, hisnr-1);
-		BLI_snprintf(tempname2, sizeof(tempname2), "%s%d", name, hisnr);
-	
-		if (BLI_rename(tempname1, tempname2)) {
-			BKE_report(reports, RPT_ERROR, "Unable to make version backup");
-			return 1;
+		if (BLI_exists(tempname1)) {
+			BLI_snprintf(tempname2, sizeof(tempname2), "%s%d", name, hisnr);
+
+			if (BLI_rename(tempname1, tempname2)) {
+				BKE_report(reports, RPT_ERROR, "Unable to make version backup");
+				return true;
+			}
 		}
 		hisnr--;
 	}
 
 	/* is needed when hisnr==1 */
-	BLI_snprintf(tempname1, sizeof(tempname1), "%s%d", name, hisnr);
+	if (BLI_exists(name)) {
+		BLI_snprintf(tempname1, sizeof(tempname1), "%s%d", name, hisnr);
 
-	if (BLI_rename(name, tempname1)) {
-		BKE_report(reports, RPT_ERROR, "Unable to make version backup");
-		return 1;
+		if (BLI_rename(name, tempname1)) {
+			BKE_report(reports, RPT_ERROR, "Unable to make version backup");
+			return true;
+		}
 	}
 
 	return 0;




More information about the Bf-blender-cvs mailing list