@@ -40,7 +40,6 @@ export class RtcContentProvider implements IContentProvider {
4040 this . _currentDrive = options . currentDrive ;
4141 this . _providers = new Map < string , MyProvider > ( ) ;
4242 this . sharedModelFactory = new SharedModelFactory ( this . _onCreate ) ;
43- this . _saveLock = new AsyncLock ( ) ;
4443 }
4544
4645 /**
@@ -138,22 +137,7 @@ export class RtcContentProvider implements IContentProvider {
138137 localPath : string ,
139138 options : Partial < Contents . IModel > & Contents . IContentProvisionOptions = { }
140139 ) : Promise < Contents . IModel > {
141- // Check that there is a provider - it won't e.g. if the document model is not collaborative.
142- if ( options . format && options . type ) {
143- const key = `${ options . format } :${ options . type } :${ localPath } ` ;
144- const provider = this . _providers . get ( key ) ;
145-
146- if ( provider ) {
147- // Save is done from the backend
148- const fetchOptions : Contents . IFetchOptions = {
149- type : options . type ,
150- format : options . format ,
151- content : false
152- } ;
153- return this . get ( localPath , fetchOptions ) ;
154- }
155- }
156-
140+ // my-jupyter-shared-drive relies on the official save logic
157141 return await this . _currentDrive . save ( localPath , {
158142 ...options ,
159143 contentProviderId : undefined
@@ -225,31 +209,6 @@ export class RtcContentProvider implements IContentProvider {
225209 provider . setSource ( content ) ;
226210 } ) ;
227211
228- sharedModel . ydoc . on ( 'update' , ( update , origin ) => {
229- if ( origin === this ) {
230- return ;
231- }
232- this . _saveLock . promise . then ( ( ) => {
233- this . _saveLock . enable ( ) ;
234- let content = sharedModel . getSource ( ) ;
235- sharedModel . ydoc . transact ( ( ) => {
236- sharedModel . ystate . set ( 'dirty' , false ) ;
237- } , this ) ;
238- if ( options . format === 'text' && typeof content === 'object' ) {
239- content = JSON . stringify ( content ) ;
240- }
241- this . _app . serviceManager . contents
242- . save ( options . path , {
243- content,
244- format : options . format ,
245- type : options . contentType
246- } )
247- . then ( ( ) => {
248- this . _saveLock . disable ( ) ;
249- } ) ;
250- } ) ;
251- } ) ;
252-
253212 sharedModel . disposed . connect ( ( ) => {
254213 const provider = this . _providers . get ( key ) ;
255214 if ( provider ) {
@@ -267,7 +226,6 @@ export class RtcContentProvider implements IContentProvider {
267226 private _trans : TranslationBundle ;
268227 private _providers : Map < string , MyProvider > ;
269228 private _ydriveFileChanged = new Signal < this, Contents . IChangedArgs > ( this ) ;
270- private _saveLock : AsyncLock ;
271229}
272230
273231/**
@@ -337,17 +295,3 @@ class SharedModelFactory implements ISharedModelFactory {
337295 return ;
338296 }
339297}
340-
341- class AsyncLock {
342- constructor ( ) {
343- this . disable = ( ) => { } ;
344- this . promise = Promise . resolve ( ) ;
345- }
346-
347- enable ( ) {
348- this . promise = new Promise ( resolve => ( this . disable = resolve ) ) ;
349- }
350-
351- disable : any ;
352- promise : Promise < void > ;
353- }
0 commit comments