mirror of
https://github.com/zyedidia/micro.git
synced 2026-03-30 06:37:14 +09:00
backup: Keep path of stored & hashed backup files in a own $hash.path file
Since full escaped backup paths can become longer than the maximum filename size and hashed filenames cannot be restored it is helpful to have a lookup file for the user to resolve the hashed path.
This commit is contained in:
@@ -39,8 +39,20 @@ func (b *Buffer) Serialize() error {
|
||||
return err
|
||||
}
|
||||
|
||||
name := util.DetermineEscapePath(filepath.Join(config.ConfigDir, "buffers"), b.AbsPath)
|
||||
return util.SafeWrite(name, buf.Bytes(), true)
|
||||
name, resolveName := util.DetermineEscapePath(filepath.Join(config.ConfigDir, "buffers"), b.AbsPath)
|
||||
err = util.SafeWrite(name, buf.Bytes(), true)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if resolveName != "" {
|
||||
err = util.SafeWrite(resolveName, []byte(b.AbsPath), true)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// Unserialize loads the buffer info from config.ConfigDir/buffers
|
||||
@@ -50,7 +62,8 @@ func (b *Buffer) Unserialize() error {
|
||||
if b.Path == "" {
|
||||
return nil
|
||||
}
|
||||
file, err := os.Open(util.DetermineEscapePath(filepath.Join(config.ConfigDir, "buffers"), b.AbsPath))
|
||||
name, _ := util.DetermineEscapePath(filepath.Join(config.ConfigDir, "buffers"), b.AbsPath)
|
||||
file, err := os.Open(name)
|
||||
if err == nil {
|
||||
defer file.Close()
|
||||
var buffer SerializedBuffer
|
||||
|
||||
Reference in New Issue
Block a user