# repl: Save notebooks through the project instead of the local filesystem \(\#62602\) · gitcafe/zed

[View on GitCafe](https://git.cafe/gitcafe/zed/commit/bc538def4545534201bbfcac4e95ac34ea6501b6)

Repository: [gitcafe/zed](https://git.cafe/gitcafe/zed)

Visibility: public

Requested revision: bc538def4545534201bbfcac4e95ac34ea6501b6

Requested commit: bc538def4545534201bbfcac4e95ac34ea6501b6

Commit: bc538def4545534201bbfcac4e95ac34ea6501b6

Tree: ff052280b8a14fba7b45d6845de28af2d22d1399

Author: Arnesh

Committer: GitHub

## Message

```
repl: Save notebooks through the project instead of the local filesystem (#62602)

Closes #59001

Saving a notebook wrote the file with
`project.fs().atomic_write(abs_path, ...)`. `Project::fs()` is always
the client's own filesystem, so for a remote project the remote path was
resolved against the local machine: on Windows the drive letter got
prepended and the atomic-write temp file used a backslash, producing
`C:/data/project/src_example\.tmpPuzw3d3` and `os error 3`. The same
thing fails on macOS/Linux clients with `os error 2`.

Both `save` and `save_as` now go through the project's buffer machinery
instead: open the buffer for the notebook's `ProjectPath`, set its text
to the serialized notebook, then `save_buffer` / `save_buffer_as`.
Writes are routed over the remote connection for remote projects, and
the open buffer stays in sync locally.

`save_as` also updates the item's project path and entry id, since
`save_buffer_as` moves the buffer to the new path and otherwise the next
save would write back to the old file.

Added a test that edits a cell, saves, and checks that the notebook
buffer held by the project reflects the saved file. It fails against the
old implementation.

Release Notes:

- N/A

---------

Co-authored-by: Finn Evers <finn.evers@outlook.de>
```

## Parents

- [f4199ae04c41eda02b65b869b301c90c97c77ca4](https://git.cafe/gitcafe/zed/commit/f4199ae04c41eda02b65b869b301c90c97c77ca4?format=markdown)

[Source at this commit](https://git.cafe/gitcafe/zed/tree/bc538def4545534201bbfcac4e95ac34ea6501b6?format=markdown)
