mirror of
https://github.com/osmarks/mycorrhiza.git
synced 2025-01-21 07:46:52 +00:00
Migrate away from ioutil
This commit is contained in:
parent
b87583ef28
commit
3dccbd602c
@ -1,8 +1,8 @@
|
||||
package hyphae
|
||||
|
||||
import (
|
||||
"io/ioutil"
|
||||
"log"
|
||||
"os"
|
||||
"path/filepath"
|
||||
|
||||
"github.com/bouncepaw/mycorrhiza/mimetype"
|
||||
@ -33,7 +33,7 @@ func Index(path string) {
|
||||
|
||||
// indexHelper finds all hypha files in the full `path` and sends them to the channel. Handling of duplicate entries and attachment and counting them is up to the caller.
|
||||
func indexHelper(path string, nestLevel uint, ch chan *Hypha) {
|
||||
nodes, err := ioutil.ReadDir(path)
|
||||
nodes, err := os.ReadDir(path)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
@ -3,7 +3,7 @@ package shroom
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"io"
|
||||
"log"
|
||||
"mime/multipart"
|
||||
"os"
|
||||
@ -45,7 +45,7 @@ func UploadText(h *hyphae.Hypha, data []byte, message string, u *user.User) (hop
|
||||
func UploadBinary(h *hyphae.Hypha, mime string, file multipart.File, u *user.User) (*history.HistoryOp, string) {
|
||||
var (
|
||||
hop = history.Operation(history.TypeEditBinary).WithMsg(fmt.Sprintf("Upload binary part for ‘%s’ with type ‘%s’", h.Name, mime))
|
||||
data, err = ioutil.ReadAll(file)
|
||||
data, err = io.ReadAll(file)
|
||||
)
|
||||
|
||||
if err != nil {
|
||||
@ -80,7 +80,7 @@ func uploadHelp(h *hyphae.Hypha, hop *history.HistoryOp, ext string, data []byte
|
||||
return hop.WithErrAbort(err), err.Error()
|
||||
}
|
||||
|
||||
if err := ioutil.WriteFile(fullPath, data, 0666); err != nil {
|
||||
if err := os.WriteFile(fullPath, data, 0666); err != nil {
|
||||
return hop.WithErrAbort(err), err.Error()
|
||||
}
|
||||
|
||||
|
@ -1,7 +1,6 @@
|
||||
package shroom
|
||||
|
||||
import (
|
||||
"io/ioutil"
|
||||
"os"
|
||||
|
||||
"github.com/bouncepaw/mycorrhiza/cfg"
|
||||
@ -13,7 +12,7 @@ func FetchTextPart(h *hyphae.Hypha) (string, error) {
|
||||
if h.TextPath == "" {
|
||||
return "", nil
|
||||
}
|
||||
text, err := ioutil.ReadFile(h.TextPath)
|
||||
text, err := os.ReadFile(h.TextPath)
|
||||
if os.IsNotExist(err) {
|
||||
return "", nil
|
||||
} else if err != nil {
|
||||
@ -26,7 +25,7 @@ func SetHeaderLinks() {
|
||||
if userLinksHypha := hyphae.ByName(cfg.HeaderLinksHypha); !userLinksHypha.Exists {
|
||||
cfg.SetDefaultHeaderLinks()
|
||||
} else {
|
||||
contents, err := ioutil.ReadFile(userLinksHypha.TextPath)
|
||||
contents, err := os.ReadFile(userLinksHypha.TextPath)
|
||||
if err != nil || len(contents) == 0 {
|
||||
cfg.SetDefaultHeaderLinks()
|
||||
} else {
|
||||
|
@ -4,7 +4,6 @@ import (
|
||||
"fmt"
|
||||
"github.com/bouncepaw/mycomarkup/mycocontext"
|
||||
"github.com/bouncepaw/mycorrhiza/cfg"
|
||||
"io/ioutil"
|
||||
"log"
|
||||
"net/http"
|
||||
"os"
|
||||
@ -123,7 +122,7 @@ func handlerHypha(w http.ResponseWriter, rq *http.Request) {
|
||||
u = user.FromRequest(rq)
|
||||
)
|
||||
if h.Exists {
|
||||
fileContentsT, errT := ioutil.ReadFile(h.TextPath)
|
||||
fileContentsT, errT := os.ReadFile(h.TextPath)
|
||||
_, errB := os.Stat(h.BinaryPath)
|
||||
if errT == nil {
|
||||
ctx, _ := mycocontext.ContextFromStringInput(hyphaName, string(fileContentsT))
|
||||
|
Loading…
Reference in New Issue
Block a user