mirror of
https://github.com/osmarks/mycorrhiza.git
synced 2024-12-04 18:19: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 (
|
import (
|
||||||
"log"
|
"log"
|
||||||
|
"log/slog"
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
|
||||||
@ -27,11 +28,10 @@ func Index(path string) {
|
|||||||
switch foundHypha := foundHypha.(type) {
|
switch foundHypha := foundHypha.(type) {
|
||||||
case *TextualHypha: // conflict! overwrite
|
case *TextualHypha: // conflict! overwrite
|
||||||
storedHypha.mycoFilePath = foundHypha.mycoFilePath
|
storedHypha.mycoFilePath = foundHypha.mycoFilePath
|
||||||
log.Printf(
|
slog.Info("File collision",
|
||||||
"File collision for hypha ‘%s’, using ‘%s’ rather than ‘%s’\n",
|
"hypha", foundHypha.CanonicalName(),
|
||||||
foundHypha.CanonicalName(),
|
"usingFile", foundHypha.TextFilePath(),
|
||||||
foundHypha.TextFilePath(),
|
"insteadOf", storedHypha.TextFilePath(),
|
||||||
storedHypha.TextFilePath(),
|
|
||||||
)
|
)
|
||||||
case *MediaHypha: // no conflict
|
case *MediaHypha: // no conflict
|
||||||
Insert(ExtendTextualToMedia(storedHypha, foundHypha.mediaFilePath))
|
Insert(ExtendTextualToMedia(storedHypha, foundHypha.mediaFilePath))
|
||||||
@ -43,11 +43,11 @@ func Index(path string) {
|
|||||||
storedHypha.mycoFilePath = foundHypha.mycoFilePath
|
storedHypha.mycoFilePath = foundHypha.mycoFilePath
|
||||||
case *MediaHypha: // conflict! overwrite
|
case *MediaHypha: // conflict! overwrite
|
||||||
storedHypha.mediaFilePath = foundHypha.mediaFilePath
|
storedHypha.mediaFilePath = foundHypha.mediaFilePath
|
||||||
log.Printf(
|
|
||||||
"File collision for hypha ‘%s’, using ‘%s’ rather than ‘%s’\n",
|
slog.Info("File collision",
|
||||||
foundHypha.CanonicalName(),
|
"hypha", foundHypha.CanonicalName(),
|
||||||
foundHypha.MediaFilePath(),
|
"usingFile", foundHypha.MediaFilePath(),
|
||||||
storedHypha.MediaFilePath(),
|
"insteadOf", storedHypha.MediaFilePath(),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -15,6 +15,7 @@ import (
|
|||||||
"mime/multipart"
|
"mime/multipart"
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
"strings"
|
||||||
)
|
)
|
||||||
|
|
||||||
func historyMessageForTextUpload(h hyphae.Hypha, userMessage string) string {
|
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) {
|
switch h := h.(type) {
|
||||||
case *hyphae.EmptyHypha:
|
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)
|
err := writeTextToDisk(H, data, hop)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -139,7 +142,8 @@ func writeMediaToDisk(h hyphae.Hypha, mime string, data []byte) (string, error)
|
|||||||
var (
|
var (
|
||||||
ext = mimetype.ToExtension(mime)
|
ext = mimetype.ToExtension(mime)
|
||||||
// That's where the file will go
|
// 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 {
|
if err := os.MkdirAll(filepath.Dir(uploadedFilePath), 0777); err != nil {
|
||||||
|
Loading…
Reference in New Issue
Block a user