mirror of
https://github.com/osmarks/mycorrhiza.git
synced 2024-12-04 01:59:54 +00:00
Hopefully fix some bugs on Windows
This commit is contained in:
parent
9ef08fb42d
commit
a0ec4f5fbf
@ -2,6 +2,7 @@ package hyphae
|
||||
|
||||
import (
|
||||
"log"
|
||||
"log/slog"
|
||||
"os"
|
||||
"path/filepath"
|
||||
|
||||
@ -27,11 +28,10 @@ func Index(path string) {
|
||||
switch foundHypha := foundHypha.(type) {
|
||||
case *TextualHypha: // conflict! overwrite
|
||||
storedHypha.mycoFilePath = foundHypha.mycoFilePath
|
||||
log.Printf(
|
||||
"File collision for hypha ‘%s’, using ‘%s’ rather than ‘%s’\n",
|
||||
foundHypha.CanonicalName(),
|
||||
foundHypha.TextFilePath(),
|
||||
storedHypha.TextFilePath(),
|
||||
slog.Info("File collision",
|
||||
"hypha", foundHypha.CanonicalName(),
|
||||
"usingFile", foundHypha.TextFilePath(),
|
||||
"insteadOf", storedHypha.TextFilePath(),
|
||||
)
|
||||
case *MediaHypha: // no conflict
|
||||
Insert(ExtendTextualToMedia(storedHypha, foundHypha.mediaFilePath))
|
||||
@ -43,11 +43,11 @@ func Index(path string) {
|
||||
storedHypha.mycoFilePath = foundHypha.mycoFilePath
|
||||
case *MediaHypha: // conflict! overwrite
|
||||
storedHypha.mediaFilePath = foundHypha.mediaFilePath
|
||||
log.Printf(
|
||||
"File collision for hypha ‘%s’, using ‘%s’ rather than ‘%s’\n",
|
||||
foundHypha.CanonicalName(),
|
||||
foundHypha.MediaFilePath(),
|
||||
storedHypha.MediaFilePath(),
|
||||
|
||||
slog.Info("File collision",
|
||||
"hypha", foundHypha.CanonicalName(),
|
||||
"usingFile", foundHypha.MediaFilePath(),
|
||||
"insteadOf", storedHypha.MediaFilePath(),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
@ -15,6 +15,7 @@ import (
|
||||
"mime/multipart"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
)
|
||||
|
||||
func historyMessageForTextUpload(h hyphae.Hypha, userMessage string) string {
|
||||
@ -78,7 +79,9 @@ func UploadText(h hyphae.Hypha, data []byte, userMessage string, u *user.User) e
|
||||
|
||||
switch h := h.(type) {
|
||||
case *hyphae.EmptyHypha:
|
||||
H := hyphae.ExtendEmptyToTextual(h, filepath.Join(files.HyphaeDir(), h.CanonicalName()+".myco"))
|
||||
parts := []string{files.HyphaeDir()}
|
||||
parts = append(parts, strings.Split(h.CanonicalName()+".myco", "\\")...)
|
||||
H := hyphae.ExtendEmptyToTextual(h, filepath.Join(parts...))
|
||||
|
||||
err := writeTextToDisk(H, data, hop)
|
||||
if err != nil {
|
||||
@ -139,7 +142,8 @@ func writeMediaToDisk(h hyphae.Hypha, mime string, data []byte) (string, error)
|
||||
var (
|
||||
ext = mimetype.ToExtension(mime)
|
||||
// That's where the file will go
|
||||
uploadedFilePath = filepath.Join(files.HyphaeDir(), h.CanonicalName()+ext)
|
||||
|
||||
uploadedFilePath = filepath.Join(append([]string{files.HyphaeDir()}, strings.Split(h.CanonicalName()+ext, "\\")...)...)
|
||||
)
|
||||
|
||||
if err := os.MkdirAll(filepath.Dir(uploadedFilePath), 0777); err != nil {
|
||||
|
Loading…
Reference in New Issue
Block a user