jupyter_server icon indicating copy to clipboard operation
jupyter_server copied to clipboard

Check file changes based on content instead of the last_modified metadata

Open skukhtichev opened this issue 5 years ago • 3 comments

JupyterLab mechanism to detect a file changes is based on last_modified parameter set in the metadata: https://github.com/jupyterlab/jupyterlab/blob/b4db7f03d2ad0b91a9c8c252c56ae5e4a9408fbb/packages/docregistry/src/context.ts#L644-L649. If the file last_modified parameter was changed without changing the content then JupyterLab shows the following message

image (11)

The issue happens when sync tools are used that updates files last modified timestamp.

Using content based check mechanism (e.g. hash) will prevent showing the dialog when the last modified timestamp changed without changing a file content

skukhtichev avatar Feb 10 '21 18:02 skukhtichev

I think it makes sense to have both. Check last_modified time, and if that has changed, then check content. That way you are usually doing the cheaper check.

jasongrout avatar Feb 10 '21 22:02 jasongrout

@jasongrout - are you suggesting the hash computation be performed by the client (lab)? That would prevent adding the hash value to the model and dealing with the impact to custom content managers and all that implies. So, would it look something like this (for those that want this form of checking):

  1. Lab fetches content (file or notebook) and stores last-modification and computes/stores checksum
  2. Upon save request, Lab fetches model (sans content) and checks last-modification against original. If different and content-based check is desired) Lab fetches content and computes/compares checksum against original and acts accordingly.

How does the fetch of the model - just prior to save - work today? I'm assuming the content is not included in that case. If that's not the case (and content is returned here as well), then we'd just need to conditionally recompute the checksum.

kevin-bates avatar Feb 10 '21 23:02 kevin-bates

xref https://github.com/jupyterlab/jupyterlab/issues/9769

blink1073 avatar Feb 11 '21 16:02 blink1073