@@ -41,6 +41,14 @@ class OWSaveBase(widget.OWWidget, openclass=True):
4141 class Information (widget .OWWidget .Information ):
4242 empty_input = widget .Msg ("Empty input; nothing was saved." )
4343
44+ class Warning (widget .OWWidget .Warning ):
45+ auto_save_disabled = widget .Msg (
46+ "Auto save disabled.\n "
47+ "Due to security reasons auto save is only restored for paths "
48+ "that are in the same directory as the workflow file or in a "
49+ "subtree of that directory."
50+ )
51+
4452 class Error (widget .OWWidget .Error ):
4553 no_file_name = widget .Msg ("File name is not set." )
4654 unsupported_format = widget .Msg ("File format is unsupported.\n {}" )
@@ -59,7 +67,7 @@ class Error(widget.OWWidget.Error):
5967 # workflow).
6068 stored_path = Setting ("" )
6169 stored_name = Setting ("" , schema_only = True ) # File name, without path
62- auto_save = Setting (False )
70+ auto_save = Setting (False , schema_only = True )
6371
6472 filters = []
6573
@@ -77,6 +85,7 @@ def __init__(self, start_row=0):
7785 """
7886 super ().__init__ ()
7987 self .data = None
88+ self .__show_auto_save_disabled = False
8089 self ._absolute_path = self ._abs_path_from_setting ()
8190
8291 # This cannot be done outside because `filters` is defined by subclass
@@ -88,7 +97,7 @@ def __init__(self, start_row=0):
8897 grid .addWidget (
8998 gui .checkBox (
9099 None , self , "auto_save" , "Autosave when receiving new data" ,
91- callback = self .update_messages ),
100+ callback = self ._on_auto_save_toggled ),
92101 start_row , 0 , 1 , 2 )
93102 self .bt_save = gui .button (
94103 self .buttonsArea , self ,
@@ -129,7 +138,7 @@ def _abs_path_from_setting(self):
129138 workflow_dir = self .workflowEnv ().get ("basedir" )
130139 if os .path .isabs (self .stored_path ):
131140 if os .path .exists (self .stored_path ):
132- self .auto_save = False
141+ self ._disable_auto_save_and_warn ()
133142 return self .stored_path
134143 elif workflow_dir is not None :
135144 return os .path .normpath (
@@ -139,6 +148,15 @@ def _abs_path_from_setting(self):
139148 self .auto_save = False
140149 return self .stored_path
141150
151+ def _disable_auto_save_and_warn (self ):
152+ if self .auto_save :
153+ self .__show_auto_save_disabled = True
154+ self .auto_save = False
155+
156+ def _on_auto_save_toggled (self ):
157+ self .__show_auto_save_disabled = False
158+ self .update_messages ()
159+
142160 @property
143161 def filename (self ):
144162 if self .stored_name :
@@ -264,6 +282,7 @@ def update_messages(self):
264282 """
265283 self .Error .no_file_name (shown = not self .filename and self .auto_save )
266284 self .Information .empty_input (shown = self .filename and self .data is None )
285+ self .Warning .auto_save_disabled (shown = self .__show_auto_save_disabled )
267286
268287 def update_status (self ):
269288 """
0 commit comments