Writefile: only include recovery info in auto-save & quit.blend
Previously all blend files included the path they were saved, causing files distributed publicly to include users local paths. This also included developers home directories for startup & userprefs defaults & app-templates bundled with Blender. Now recovery information is only written for auto-save & quit.blend since this is the only time they're intended to be used.
This commit is contained in:
@@ -179,6 +179,14 @@ enum {
|
|||||||
* so keep this as a flag.
|
* so keep this as a flag.
|
||||||
*/
|
*/
|
||||||
G_FILE_RECOVER_READ = (1 << 23),
|
G_FILE_RECOVER_READ = (1 << 23),
|
||||||
|
/**
|
||||||
|
* On write, assign use #FileGlobal.filename, otherwise leave it blank,
|
||||||
|
* needed so files can be recovered at their original locations.
|
||||||
|
*
|
||||||
|
* \note only #BLENDER_QUIT_FILE and auto-save files include recovery information.
|
||||||
|
* As users/developers may not want their paths exposed in publicly distributed files.
|
||||||
|
*/
|
||||||
|
G_FILE_RECOVER_WRITE = (1 << 24),
|
||||||
/** BMesh option to save as older mesh format */
|
/** BMesh option to save as older mesh format */
|
||||||
/* #define G_FILE_MESH_COMPAT (1 << 26) */
|
/* #define G_FILE_MESH_COMPAT (1 << 26) */
|
||||||
/* #define G_FILE_GLSL_NO_ENV_LIGHTING (1 << 28) */ /* deprecated */
|
/* #define G_FILE_GLSL_NO_ENV_LIGHTING (1 << 28) */ /* deprecated */
|
||||||
@@ -188,7 +196,7 @@ enum {
|
|||||||
* Run-time only #G.fileflags which are never read or written to/from Blend files.
|
* Run-time only #G.fileflags which are never read or written to/from Blend files.
|
||||||
* This means we can change the values without worrying about do-versions.
|
* This means we can change the values without worrying about do-versions.
|
||||||
*/
|
*/
|
||||||
#define G_FILE_FLAG_ALL_RUNTIME (G_FILE_NO_UI)
|
#define G_FILE_FLAG_ALL_RUNTIME (G_FILE_NO_UI | G_FILE_RECOVER_READ | G_FILE_RECOVER_WRITE)
|
||||||
|
|
||||||
/** ENDIAN_ORDER: indicates what endianness the platform where the file was written had. */
|
/** ENDIAN_ORDER: indicates what endianness the platform where the file was written had. */
|
||||||
#if !defined(__BIG_ENDIAN__) && !defined(__LITTLE_ENDIAN__)
|
#if !defined(__BIG_ENDIAN__) && !defined(__LITTLE_ENDIAN__)
|
||||||
|
|||||||
@@ -115,6 +115,9 @@ MemFileUndoData *BKE_memfile_undo_encode(Main *bmain, MemFileUndoData *mfu_prev)
|
|||||||
{
|
{
|
||||||
MemFileUndoData *mfu = MEM_callocN(sizeof(MemFileUndoData), __func__);
|
MemFileUndoData *mfu = MEM_callocN(sizeof(MemFileUndoData), __func__);
|
||||||
|
|
||||||
|
/* Include recovery infomation since undo-data is written out as #BLENDER_QUIT_FILE. */
|
||||||
|
const int fileflags = G.fileflags | G_FILE_RECOVER_WRITE;
|
||||||
|
|
||||||
/* disk save version */
|
/* disk save version */
|
||||||
if (UNDO_DISK) {
|
if (UNDO_DISK) {
|
||||||
static int counter = 0;
|
static int counter = 0;
|
||||||
@@ -129,7 +132,7 @@ MemFileUndoData *BKE_memfile_undo_encode(Main *bmain, MemFileUndoData *mfu_prev)
|
|||||||
BLI_join_dirfile(filename, sizeof(filename), BKE_tempdir_session(), numstr);
|
BLI_join_dirfile(filename, sizeof(filename), BKE_tempdir_session(), numstr);
|
||||||
|
|
||||||
/* success = */ /* UNUSED */ BLO_write_file(
|
/* success = */ /* UNUSED */ BLO_write_file(
|
||||||
bmain, filename, G.fileflags, &(const struct BlendFileWriteParams){0}, NULL);
|
bmain, filename, fileflags, &(const struct BlendFileWriteParams){0}, NULL);
|
||||||
|
|
||||||
BLI_strncpy(mfu->filename, filename, sizeof(mfu->filename));
|
BLI_strncpy(mfu->filename, filename, sizeof(mfu->filename));
|
||||||
}
|
}
|
||||||
@@ -138,7 +141,7 @@ MemFileUndoData *BKE_memfile_undo_encode(Main *bmain, MemFileUndoData *mfu_prev)
|
|||||||
if (prevfile) {
|
if (prevfile) {
|
||||||
BLO_memfile_clear_future(prevfile);
|
BLO_memfile_clear_future(prevfile);
|
||||||
}
|
}
|
||||||
/* success = */ /* UNUSED */ BLO_write_file_mem(bmain, prevfile, &mfu->memfile, G.fileflags);
|
/* success = */ /* UNUSED */ BLO_write_file_mem(bmain, prevfile, &mfu->memfile, fileflags);
|
||||||
mfu->undo_size = mfu->memfile.size;
|
mfu->undo_size = mfu->memfile.size;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -870,7 +870,10 @@ static void write_global(WriteData *wd, int fileflags, Main *mainvar)
|
|||||||
fg.fileflags = (fileflags & ~G_FILE_FLAG_ALL_RUNTIME);
|
fg.fileflags = (fileflags & ~G_FILE_FLAG_ALL_RUNTIME);
|
||||||
|
|
||||||
fg.globalf = G.f;
|
fg.globalf = G.f;
|
||||||
BLI_strncpy(fg.filename, mainvar->name, sizeof(fg.filename));
|
/* Write information needed for recovery. */
|
||||||
|
if (fileflags & G_FILE_RECOVER_WRITE) {
|
||||||
|
BLI_strncpy(fg.filename, mainvar->name, sizeof(fg.filename));
|
||||||
|
}
|
||||||
sprintf(subvstr, "%4d", BLENDER_FILE_SUBVERSION);
|
sprintf(subvstr, "%4d", BLENDER_FILE_SUBVERSION);
|
||||||
memcpy(fg.subvstr, subvstr, 4);
|
memcpy(fg.subvstr, subvstr, 4);
|
||||||
|
|
||||||
|
|||||||
@@ -1682,8 +1682,8 @@ void wm_autosave_timer(Main *bmain, wmWindowManager *wm, wmTimer *UNUSED(wt))
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
/* Save as regular blend file. */
|
/* Save as regular blend file with recovery information. */
|
||||||
const int fileflags = G.fileflags & ~G_FILE_COMPRESS;
|
const int fileflags = (G.fileflags & ~G_FILE_COMPRESS) | G_FILE_RECOVER_WRITE;
|
||||||
|
|
||||||
ED_editors_flush_edits(bmain);
|
ED_editors_flush_edits(bmain);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user