|
|
|
@ -42,8 +42,7 @@ func (ch *CaddyHugo) newEditSession(docName string) (*editSession, error) { |
|
|
|
|
docname: docName, |
|
|
|
|
filename: filename, |
|
|
|
|
doc: acedoc.NewString(string(contents)), |
|
|
|
|
// tmpfs: afero.NewCopyOnWriteFs(afero.NewBasePathFs(afero.NewOsFs(), ch.Dir+"/"), afero.NewMemMapFs()),
|
|
|
|
|
tmpfs: afero.NewCopyOnWriteFs(afero.NewOsFs(), afero.NewMemMapFs()), |
|
|
|
|
tmpfs: afero.NewCopyOnWriteFs(afero.NewOsFs(), afero.NewMemMapFs()), |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
err = es.doc.LogToFile(path.Join(ch.Dir, "logs", docName)) |
|
|
|
@ -71,7 +70,7 @@ func (ch *CaddyHugo) renderDraft(es *editSession) error { |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
cfg, err := HugoCmdProcessConfig(ch, es, f) |
|
|
|
|
cfg, err := HugoInternalProcessConfig(ch, es, f) |
|
|
|
|
if err != nil { |
|
|
|
|
return fmt.Errorf("rendering draft: %v", err) |
|
|
|
|
} |
|
|
|
@ -80,7 +79,19 @@ func (ch *CaddyHugo) renderDraft(es *editSession) error { |
|
|
|
|
return proc.Start() |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
func (ch *CaddyHugo) persistEdits(es *editSession) error { |
|
|
|
|
func (ch *CaddyHugo) persistAllEdits() error { |
|
|
|
|
ch.mtx.Lock() |
|
|
|
|
defer ch.mtx.Unlock() |
|
|
|
|
for _, es := range ch.docs { |
|
|
|
|
err := ch.persistEditsForSession(es) |
|
|
|
|
if err != nil { |
|
|
|
|
return err |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
return nil |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
func (ch *CaddyHugo) persistEditsForSession(es *editSession) error { |
|
|
|
|
err := afero.WriteFile(afero.NewOsFs(), es.filename, []byte(es.doc.Contents()), 0644) |
|
|
|
|
if err != nil { |
|
|
|
|
return err |
|
|
|
|