|
|
@ -42,7 +42,6 @@ func (ch *CaddyHugo) newEditSession(docName string) (*editSession, error) { |
|
|
|
docname: docName, |
|
|
|
docname: docName, |
|
|
|
filename: filename, |
|
|
|
filename: filename, |
|
|
|
doc: acedoc.NewString(string(contents)), |
|
|
|
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()), |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -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 { |
|
|
|
if err != nil { |
|
|
|
return fmt.Errorf("rendering draft: %v", err) |
|
|
|
return fmt.Errorf("rendering draft: %v", err) |
|
|
|
} |
|
|
|
} |
|
|
@ -80,7 +79,19 @@ func (ch *CaddyHugo) renderDraft(es *editSession) error { |
|
|
|
return proc.Start() |
|
|
|
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) |
|
|
|
err := afero.WriteFile(afero.NewOsFs(), es.filename, []byte(es.doc.Contents()), 0644) |
|
|
|
if err != nil { |
|
|
|
if err != nil { |
|
|
|
return err |
|
|
|
return err |
|
|
|