]> git.giacomolli.uk - onechat/blobdiff - memory.go
Revert the block parts of the compaction view
[onechat] / memory.go
index 733673bf8607b50019e8417a80d4d0d9c6352151..cb55cab9820de7f5cda2436921312c1d1cd31f56 100644 (file)
--- a/memory.go
+++ b/memory.go
@@ -529,25 +529,3 @@ func (m *Memory) context(level, index int) string {
 
        return m.cview.Context(end)
 }
-
-// writeFileAtomic replaces the file at path with data through a temporary file
-// and a rename. A reader or a crash of the process sees the old file or the new
-// file, never a part of one.
-func writeFileAtomic(path string, data []byte) error {
-       file, err := os.CreateTemp(filepath.Dir(path), "."+filepath.Base(path)+".*")
-       if err != nil {
-               return fmt.Errorf("create temporary file: %w", err)
-       }
-
-       _, err = file.Write(data)
-       err = errors.Join(err, file.Close())
-       if err == nil {
-               err = os.Rename(file.Name(), path)
-       }
-
-       if err != nil {
-               return errors.Join(fmt.Errorf("replace file: %w", err), os.Remove(file.Name()))
-       }
-
-       return nil
-}