@@ -29,19 +29,21 @@ class DirectoryUuid():
2929 implement a ContextManager that return a (uuid, local path).
3030 """
3131
32- def __init__ (self , workspace_directory , api_base : str , uuid = None ):
32+ def __init__ (self , workspace_directory , api_base : str , uuid = None , autosave = True ):
3333 """
3434 :param uuid: Directory UUID.
3535 :param api_base: Api base URL.
3636 :param work_directory: Local directory used to store file. If you use local protocol you may use
3737 a folder on the same partition so that cp will be hard link.
38+ :param autosave: Save changed data on the server at exit or context manager close (Default: True).
3839 """
3940 self .__api_base = api_base
4041 self .__workspace_directory = workspace_directory
4142 self ._uuid = uuid if uuid is not None else self .__generate_uuid ()
4243 self ._syncable_local = None
4344 self ._syncable_remote = None # User need to define it in their implementation
4445 self .__create_local_directory ()
46+ self ._autosave = autosave
4547
4648 # Fetching files for existing uuids
4749 if uuid is not None :
@@ -181,10 +183,12 @@ def __exit__(self, type, value, traceback):
181183 Context manager.
182184 Save files back to server.
183185 """
184- self .save ()
186+ if self ._autosave :
187+ self .save ()
185188
186189 def __del__ (self ):
187190 """
188191 Save files back to server. Might not be called.
189192 """
190- self .save ()
193+ if self ._autosave :
194+ self .save ()
0 commit comments