Brush Assets: Better detection & protection for asset system files #124246

Merged
Julian Eisel merged 2 commits from JulianEisel/blender:temp-asset-file-flag-protect into brush-assets-project 2024-07-05 18:35:11 +02:00
Member

Only relying on the .asset.blend extension was weak, it was too easy to save
files this way. Not just by manually naming files, but also by using "Save As"
on such a file (as suggested by previous the warning popup), without actually
changing the file name.

Instead, additionally set a flag for asset system files, only treat these as
writable by the asset system, and disallow overriding them manually.

  • Opening an asset system file shows a warning.
  • The status bar shows a permanent warning for such a file.
  • Attempting to save such an asset system file will fail with a warning popup.
    It lets you choose to cancel or use "Save As" instead, but not override the
    file.
  • When using "Save As" from an asset system file, the .asset.blend is replaced
    with .blend
  • An additional check in the main .blend file writing function prevents
    writing files as asset system files if they are not identified as such.

This should prevent us from any unintentional user data loss through file
saving and asset editing.

Files may still manually be named .asset.blend now. They are just normal
.blend files.

Only relying on the .asset.blend extension was weak, it was too easy to save files this way. Not just by manually naming files, but also by using "Save As" on such a file (as suggested by previous the warning popup), without actually changing the file name. Instead, additionally set a flag for asset system files, only treat these as writable by the asset system, and disallow overriding them manually. - Opening an asset system file shows a warning. <br/><img src="https://projects.blender.org/attachments/b81fa58a-ac2f-4284-9705-87fb6ff4f4b1" width="500px"/> - The status bar shows a permanent warning for such a file. - Attempting to save such an asset system file will fail with a warning popup. It lets you choose to cancel or use "Save As" instead, but not override the file. <br/> <img src="https://projects.blender.org/attachments/4030c1a2-481e-40f0-938c-1845e1591e22" width="500px"/> - When using "Save As" from an asset system file, the .asset.blend is replaced with .blend - An additional check in the main .blend file writing function prevents writing files as asset system files if they are not identified as such. This should prevent us from any unintentional user data loss through file saving and asset editing. Files may still manually be named .asset.blend now. They are just normal .blend files.
Julian Eisel added 1 commit 2024-07-05 17:14:23 +02:00
Only relying on the .asset.blend extension was weak, it was too easy to save
files this way. Not just by manually naming files, but also by using "Save As"
on such a file (as suggested by previous the warning popup), without actually
changing the file name.

Instead, additionally set a flag for asset system files, only treat these as
writable by the asset system, and disallow overriding them manually.

- Opening an asset system file shows a warning.
- The status bar shows a permanent warning for such a file.
- Attempting to save such an asset system file will fail with a warning popup.
  It lets you choose to cancel or use "Save As" instead, but not override the
  file.
- When using "Save As" from an asset system file, the .asset.blend is replaced
  with .blend
- An additional check in the main .blend file writing function prevents
  writing files as asset system files if they are not identified as such.

This should prevent us from any unintentional user data loss through file
saving and asset editing.

Files may still manually be named .asset.blend now. They are just normal
.blend files.
Julian Eisel added this to the Brush Assets & Asset Shelf project 2024-07-05 17:14:28 +02:00
Julian Eisel requested review from Dalai Felinto 2024-07-05 17:18:10 +02:00
Julian Eisel requested review from Bastien Montagne 2024-07-05 17:18:10 +02:00
Julian Eisel added the
Interest
Core
label 2024-07-05 17:18:25 +02:00
Bastien Montagne modified the project from Brush Assets & Asset Shelf to Core 2024-07-05 17:41:46 +02:00
Bastien Montagne modified the project from Core to Brush Assets & Asset Shelf 2024-07-05 17:41:53 +02:00
Bastien Montagne added the
Module
Core
label 2024-07-05 17:42:34 +02:00
Bastien Montagne approved these changes 2024-07-05 18:13:24 +02:00
Bastien Montagne left a comment
Owner

Code wise change LGTM, besides a few minor comments below.

Code wise change LGTM, besides a few minor comments below.
@ -297,0 +299,4 @@
* UI, at which point the file will be regenerated by the asset system (API in
* #BKE_asset_edit.hh). Stored with a .asset.blend prefix.
*/
G_FILE_MINIMAL_ASSET_EDIT_FILE = (1 << 29),

Think you can remove the MINIMAL part?

Think you can remove the `MINIMAL` part?
JulianEisel marked this conversation as resolved
@ -458,6 +462,9 @@ static void read_file_version(FileData *fd, Main *main)
if (main->curlib) {
main->curlib->runtime.versionfile = main->versionfile;
main->curlib->runtime.subversionfile = main->subversionfile;
if (main->is_asset_edit_file) {

Just for sake of consistency, would also clear the tag if is_asset_edit_file is false?

Just for sake of consistency, would also clear the tag if `is_asset_edit_file` is `false`?
JulianEisel marked this conversation as resolved
@ -553,0 +554,4 @@
* The blend file of this library has the #G_FILE_MINIMAL_ASSET_EDIT_FILE flag set (refer to it
* for more info).
*/
LIBRARY_IS_MINIMAL_ASSET_EDIT_FILE = 1 << 3,

Would also remove MINIMAL part from this enum item.

Would also remove `MINIMAL` part from this enum item.
JulianEisel marked this conversation as resolved
Julian Eisel added 1 commit 2024-07-05 18:30:38 +02:00
Dalai Felinto approved these changes 2024-07-05 18:33:53 +02:00
Dalai Felinto left a comment
Owner

Design-wise seems good

Design-wise seems good
Julian Eisel merged commit f71d7c5794 into brush-assets-project 2024-07-05 18:35:11 +02:00
Julian Eisel deleted branch temp-asset-file-flag-protect 2024-07-05 18:35:14 +02:00
Sign in to join this conversation.
No Label
Interest
Alembic
Interest
Animation & Rigging
Interest
Asset System
Interest
Audio
Interest
Automated Testing
Interest
Blender Asset Bundle
Interest
BlendFile
Interest
Collada
Interest
Compatibility
Interest
Compositing
Interest
Core
Interest
Cycles
Interest
Dependency Graph
Interest
Development Management
Interest
EEVEE
Interest
Freestyle
Interest
Geometry Nodes
Interest
Grease Pencil
Interest
ID Management
Interest
Images & Movies
Interest
Import Export
Interest
Line Art
Interest
Masking
Interest
Metal
Interest
Modeling
Interest
Modifiers
Interest
Motion Tracking
Interest
Nodes & Physics
Interest
OpenGL
Interest
Overlay
Interest
Overrides
Interest
Performance
Interest
Physics
Interest
Pipeline, Assets & IO
Interest
Platforms, Builds & Tests
Interest
Python API
Interest
Render & Cycles
Interest
Render Pipeline
Interest
Sculpt, Paint & Texture
Interest
Text Editor
Interest
Translations
Interest
Triaging
Interest
Undo
Interest
USD
Interest
User Interface
Interest
UV Editing
Interest
VFX & Video
Interest
Video Sequencer
Interest
Viewport & EEVEE
Interest
Virtual Reality
Interest
Vulkan
Interest
Wayland
Interest
Workbench
Interest: X11
Legacy
Asset Browser Project
Legacy
Blender 2.8 Project
Legacy
Milestone 1: Basic, Local Asset Browser
Legacy
OpenGL Error
Meta
Good First Issue
Meta
Papercut
Meta
Retrospective
Meta
Security
Module
Animation & Rigging
Module
Core
Module
Development Management
Module
Grease Pencil
Module
Modeling
Module
Nodes & Physics
Module
Pipeline, Assets & IO
Module
Platforms, Builds & Tests
Module
Python API
Module
Render & Cycles
Module
Sculpt, Paint & Texture
Module
Triaging
Module
User Interface
Module
VFX & Video
Module
Viewport & EEVEE
Platform
FreeBSD
Platform
Linux
Platform
macOS
Platform
Windows
Severity
High
Severity
Low
Severity
Normal
Severity
Unbreak Now!
Status
Archived
Status
Confirmed
Status
Duplicate
Status
Needs Info from Developers
Status
Needs Information from User
Status
Needs Triage
Status
Resolved
Type
Bug
Type
Design
Type
Known Issue
Type
Patch
Type
Report
Type
To Do
No Milestone
No Assignees
3 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: blender/blender#124246
No description provided.