Overengineered. Back to basics.

Rewrote gather-media in bash. Updated dockerfile accordingly.
main
Nick Dumas 2 years ago
parent ad1c6ae0b2
commit 79c106401f

@ -1,12 +1,14 @@
FROM golang:latest as BUILD
FROM alpine
COPY gather-media.sh /bin/gather-media
#FROM golang:latest as BUILD
WORKDIR /gather-media
#WORKDIR /gather-media
COPY go.mod ./
# COPY go.sum ./
#COPY go.mod ./
## COPY go.sum ./
RUN go mod download
#RUN go mod download
COPY *.go ./
#COPY *.go ./
RUN go build -o /bin/gather-media
#RUN go build -o /bin/gather-media

@ -0,0 +1,13 @@
#! /bin/sh
echo "scanning $1 for attachments"
noteName=$(echo $1|awk -F'/' '{print $(NF-1)}')
attachments=$(cat $1|egrep "\[\[(Resources\/attachments\/.*?)\]\]"|tr -d '![]'|awk -F'/' '{print $(NF)}')
echo "Found Attachments:"
echo $attachments
for a in $attachments; do
# echo "find . -name $a -exec mv {} /tmp/blog/content/notes/$noteName/$a \;"
find . -name $a -exec mv {} /tmp/blog/content/notes/$noteName/$a \;
done

@ -34,7 +34,6 @@ func scanReader(r io.Reader, path string, matchChan matches) {
for _, match := range matches {
dirs := strings.Split(path, "/")
noteFilename := dirs[len(dirs)-2]
log.Println("noteFilename:", noteFilename)
matchChan <- Attachment{Filename: match[1], Note: noteFilename}
}
}

Loading…
Cancel
Save