diff --git a/Dockerfile b/Dockerfile index ce16f91..4bb8193 100755 --- a/Dockerfile +++ b/Dockerfile @@ -2,8 +2,7 @@ FROM frolvlad/alpine-glibc:alpine-3.9_glibc-2.29 RUN apk update \ && apk add --no-cache \ ca-certificates \ - git \ - bash \ + bash jq curl \ php php-sqlite3 php-pdo php-pdo_mysql php-json php-pdo_sqlite RUN mkdir -p /var/log diff --git a/entrypoint.sh b/entrypoint.sh index dc58858..90aa345 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -6,4 +6,12 @@ kill -9 1 ) & +( + until curl localhost:39909; do + sleep 1 + done + pushd /main/testdata + bash ./migrate.sh 192.168.0.86:44112 localhost:39909 +) & + exec /main/exec-todo-server "$@" diff --git a/server/ajax/task/task.go b/server/ajax/task/task.go index 4196697..dfa8f13 100755 --- a/server/ajax/task/task.go +++ b/server/ajax/task/task.go @@ -30,7 +30,7 @@ type Task struct { type StrList []string func (sl StrList) MarshalJSON() ([]byte, error) { - s := strings.Join(sl, ", ") + s := strings.Join(sl, ",") return json.Marshal(s) } @@ -102,7 +102,7 @@ func (t *Task) MarshalJSON() ([]byte, error) { "note": strings.Join(t.Note, "\n"), "noteText": strings.Join(t.Note, "\n"), "ow": 0, - "tags": strings.Join([]string(t.Tags), ", "), + "tags": strings.Join([]string(t.Tags), ","), "tags_ids": strings.Join([]string(tagsIds), ","), "duedate": t.Due.Format(fullFormat), "dueClass": "", diff --git a/server/ajax/task/task_test.go b/server/ajax/task/task_test.go index 698a974..00aa9c1 100755 --- a/server/ajax/task/task_test.go +++ b/server/ajax/task/task_test.go @@ -65,7 +65,7 @@ func TestJSONMarshal(t *testing.T) { json.Unmarshal(b, &m) if v, ok := m["tags"]; !ok { t.Error(ok, m) - } else if v != "a, b" { + } else if v != "a,b" { t.Error(v, m) } } diff --git a/testdata/migrate.sh b/testdata/migrate.sh index 613205b..70db8c6 100644 --- a/testdata/migrate.sh +++ b/testdata/migrate.sh @@ -30,7 +30,7 @@ function migrate_tasks() { local to_addr="$2" local from_list="$3" local to_list=$(lookup_list "$from_addr" "$from_list" "$to_addr") - local has_tasks="$(list_tasks "$to_addr" "$to_list" | base64 --decode | jq .title)" + local has_tasks="$(list_tasks "$to_addr" "$to_list" | b64decode | jq .title)" for task in $(list_tasks "$from_addr" "$from_list"); do add_task "$to_addr" "$to_list" "$task" "$has_tasks" done @@ -70,7 +70,7 @@ function list_tasks() { function add_task() { local addr="$1" local list="$2" - local task="$(echo -n "$3" | base64 --decode | jq "del(.id, .listId)")" + local task="$(echo -n "$3" | b64decode | jq "del(.id, .listId)")" local has_tasks="$4" local title="$(echo "$task" | jq -r .title)" local tags="$(echo "$task" | jq -r .tags)" @@ -105,6 +105,14 @@ function add_task() { fi } +function b64decode() { + if printf "" | base64 --decode 2> /dev/null; then + base64 --decode + else + base64 -d + fi +} + if [ "$0" == "$BASH_SOURCE" ]; then echo bash migrate.sh 192.168.0.86:44112 localhost:39909 time main "$@"