forked from vikunja/vikunja
Compare commits
10 Commits
bfcefa0217
...
4f55099896
Author | SHA1 | Date |
---|---|---|
Erwan Martin | 4f55099896 | |
kolaente | f065dcf4ad | |
kolaente | addcbdd8ca | |
kolaente | 054f21821c | |
kolaente | 38a3a5c6e8 | |
kolaente | 1ee243f2bd | |
kolaente | 191c154150 | |
kolaente | 378759e06d | |
kolaente | c5c74e9537 | |
kolaente | e34f503674 |
|
@ -438,6 +438,7 @@ steps:
|
||||||
# This path does not exist. However, when we set the gopath to /go, the build fails. Not sure why.
|
# This path does not exist. However, when we set the gopath to /go, the build fails. Not sure why.
|
||||||
# Leaving this here until we know how to resolve this properly.
|
# Leaving this here until we know how to resolve this properly.
|
||||||
GOPATH: /srv/app
|
GOPATH: /srv/app
|
||||||
|
GOPROXY: https://goproxy.kolaente.de
|
||||||
commands:
|
commands:
|
||||||
- export PATH=$PATH:$GOPATH/bin
|
- export PATH=$PATH:$GOPATH/bin
|
||||||
- go install github.com/magefile/mage
|
- go install github.com/magefile/mage
|
||||||
|
@ -451,6 +452,7 @@ steps:
|
||||||
# This path does not exist. However, when we set the gopath to /go, the build fails. Not sure why.
|
# This path does not exist. However, when we set the gopath to /go, the build fails. Not sure why.
|
||||||
# Leaving this here until we know how to resolve this properly.
|
# Leaving this here until we know how to resolve this properly.
|
||||||
GOPATH: /srv/app
|
GOPATH: /srv/app
|
||||||
|
GOPROXY: https://goproxy.kolaente.de
|
||||||
commands:
|
commands:
|
||||||
- export PATH=$PATH:$GOPATH/bin
|
- export PATH=$PATH:$GOPATH/bin
|
||||||
- go install github.com/magefile/mage
|
- go install github.com/magefile/mage
|
||||||
|
@ -464,6 +466,7 @@ steps:
|
||||||
# This path does not exist. However, when we set the gopath to /go, the build fails. Not sure why.
|
# This path does not exist. However, when we set the gopath to /go, the build fails. Not sure why.
|
||||||
# Leaving this here until we know how to resolve this properly.
|
# Leaving this here until we know how to resolve this properly.
|
||||||
GOPATH: /srv/app
|
GOPATH: /srv/app
|
||||||
|
GOPROXY: https://goproxy.kolaente.de
|
||||||
commands:
|
commands:
|
||||||
- export PATH=$PATH:$GOPATH/bin
|
- export PATH=$PATH:$GOPATH/bin
|
||||||
- go install github.com/magefile/mage
|
- go install github.com/magefile/mage
|
||||||
|
@ -775,6 +778,6 @@ steps:
|
||||||
- failure
|
- failure
|
||||||
---
|
---
|
||||||
kind: signature
|
kind: signature
|
||||||
hmac: b32ea5780ab6c4e57f201ec468357340349591a3026c96efd669a0b9c10f0e34
|
hmac: 6bc74f5b7e9c51e725100e05f07cdac656d6c3d49d19c2b112aed812c86e7a9a
|
||||||
|
|
||||||
...
|
...
|
||||||
|
|
|
@ -13,6 +13,7 @@ COPY . ./
|
||||||
|
|
||||||
ARG TARGETOS TARGETARCH TARGETVARIANT
|
ARG TARGETOS TARGETARCH TARGETVARIANT
|
||||||
|
|
||||||
|
ENV GOPROXY https://goproxy.kolaente.de
|
||||||
RUN export PATH=$PATH:$GOPATH/bin && \
|
RUN export PATH=$PATH:$GOPATH/bin && \
|
||||||
mage build:clean && \
|
mage build:clean && \
|
||||||
mage release:xgo "${TARGETOS}/${TARGETARCH}/${TARGETVARIANT}"
|
mage release:xgo "${TARGETOS}/${TARGETARCH}/${TARGETVARIANT}"
|
||||||
|
|
|
@ -453,9 +453,6 @@ func (Build) Clean() error {
|
||||||
if err := os.RemoveAll(BinLocation); err != nil && !os.IsNotExist(err) {
|
if err := os.RemoveAll(BinLocation); err != nil && !os.IsNotExist(err) {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
if err := os.RemoveAll(swaggerDocsFolderLocation); err != nil && !os.IsNotExist(err) {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -17,13 +17,13 @@
|
||||||
package caldav
|
package caldav
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"code.vikunja.io/api/pkg/db"
|
|
||||||
"errors"
|
"errors"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"code.vikunja.io/api/pkg/config"
|
"code.vikunja.io/api/pkg/config"
|
||||||
|
"code.vikunja.io/api/pkg/db"
|
||||||
"code.vikunja.io/api/pkg/log"
|
"code.vikunja.io/api/pkg/log"
|
||||||
"code.vikunja.io/api/pkg/models"
|
"code.vikunja.io/api/pkg/models"
|
||||||
"code.vikunja.io/api/pkg/utils"
|
"code.vikunja.io/api/pkg/utils"
|
||||||
|
@ -91,11 +91,11 @@ func ParseTaskFromVTODO(content string) (vTask *models.Task, err error) {
|
||||||
}
|
}
|
||||||
// We put the vTodo details in a map to be able to handle them more easily
|
// We put the vTodo details in a map to be able to handle them more easily
|
||||||
task := make(map[string]ics.IANAProperty)
|
task := make(map[string]ics.IANAProperty)
|
||||||
var relation *ics.IANAProperty
|
var relation ics.IANAProperty
|
||||||
for _, c := range vTodo.UnknownPropertiesIANAProperties() {
|
for _, c := range vTodo.UnknownPropertiesIANAProperties() {
|
||||||
task[c.IANAToken] = c
|
task[c.IANAToken] = c
|
||||||
if strings.HasPrefix(c.IANAToken, "RELATED-TO") {
|
if strings.HasPrefix(c.IANAToken, "RELATED-TO") {
|
||||||
relation = &c
|
relation = c
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -139,7 +139,7 @@ func ParseTaskFromVTODO(content string) (vTask *models.Task, err error) {
|
||||||
DoneAt: caldavTimeToTimestamp(task["COMPLETED"]),
|
DoneAt: caldavTimeToTimestamp(task["COMPLETED"]),
|
||||||
}
|
}
|
||||||
|
|
||||||
if relation != nil {
|
if relation.Value != "" {
|
||||||
s := db.NewSession()
|
s := db.NewSession()
|
||||||
defer s.Close()
|
defer s.Close()
|
||||||
|
|
||||||
|
|
|
@ -38,7 +38,7 @@ func init() {
|
||||||
ID: "20230828125443",
|
ID: "20230828125443",
|
||||||
Description: "",
|
Description: "",
|
||||||
Migrate: func(tx *xorm.Engine) error {
|
Migrate: func(tx *xorm.Engine) error {
|
||||||
return tx.Sync2(typesenseSync20230828125443{})
|
return tx.CreateTables(typesenseSync20230828125443{})
|
||||||
},
|
},
|
||||||
Rollback: func(tx *xorm.Engine) error {
|
Rollback: func(tx *xorm.Engine) error {
|
||||||
return nil
|
return nil
|
||||||
|
|
|
@ -59,6 +59,7 @@ func GetTables() []interface{} {
|
||||||
&Subscription{},
|
&Subscription{},
|
||||||
&Favorite{},
|
&Favorite{},
|
||||||
&APIToken{},
|
&APIToken{},
|
||||||
|
&TypesenseSync{},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1030,7 +1030,12 @@ func (p *Project) DeleteBackgroundFileIfExists() (err error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
file := files.File{ID: p.BackgroundFileID}
|
file := files.File{ID: p.BackgroundFileID}
|
||||||
return file.Delete()
|
err = file.Delete()
|
||||||
|
if err != nil && files.IsErrFileDoesNotExist(err) {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
// SetProjectBackground sets a background file as project background in the db
|
// SetProjectBackground sets a background file as project background in the db
|
||||||
|
|
|
@ -118,43 +118,9 @@ func (pd *ProjectDuplicate) Create(s *xorm.Session, doer web.Auth) (err error) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// Background files + unsplash info
|
err = duplicateProjectBackground(s, pd, doer)
|
||||||
if pd.Project.BackgroundFileID != 0 {
|
if err != nil {
|
||||||
|
return
|
||||||
log.Debugf("Duplicating background %d from project %d into %d", pd.Project.BackgroundFileID, pd.ProjectID, pd.Project.ID)
|
|
||||||
|
|
||||||
f := &files.File{ID: pd.Project.BackgroundFileID}
|
|
||||||
if err := f.LoadFileMetaByID(); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
if err := f.LoadFileByID(); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
defer f.File.Close()
|
|
||||||
|
|
||||||
file, err := files.Create(f.File, f.Name, f.Size, doer)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
// Get unsplash info if applicable
|
|
||||||
up, err := GetUnsplashPhotoByFileID(s, pd.Project.BackgroundFileID)
|
|
||||||
if err != nil && files.IsErrFileIsNotUnsplashFile(err) {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
if up != nil {
|
|
||||||
up.ID = 0
|
|
||||||
up.FileID = file.ID
|
|
||||||
if err := up.Save(s); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if err := SetProjectBackground(s, pd.Project.ID, file, pd.Project.BackgroundBlurHash); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
log.Debugf("Duplicated project background from project %d into %d", pd.ProjectID, pd.Project.ID)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Rights / Shares
|
// Rights / Shares
|
||||||
|
@ -207,6 +173,54 @@ func (pd *ProjectDuplicate) Create(s *xorm.Session, doer web.Auth) (err error) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func duplicateProjectBackground(s *xorm.Session, pd *ProjectDuplicate, doer web.Auth) (err error) {
|
||||||
|
if pd.Project.BackgroundFileID == 0 {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
log.Debugf("Duplicating background %d from project %d into %d", pd.Project.BackgroundFileID, pd.ProjectID, pd.Project.ID)
|
||||||
|
|
||||||
|
f := &files.File{ID: pd.Project.BackgroundFileID}
|
||||||
|
err = f.LoadFileMetaByID()
|
||||||
|
if err != nil && files.IsErrFileDoesNotExist(err) {
|
||||||
|
pd.Project.BackgroundFileID = 0
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
if err := f.LoadFileByID(); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
defer f.File.Close()
|
||||||
|
|
||||||
|
file, err := files.Create(f.File, f.Name, f.Size, doer)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get unsplash info if applicable
|
||||||
|
up, err := GetUnsplashPhotoByFileID(s, pd.Project.BackgroundFileID)
|
||||||
|
if err != nil && !files.IsErrFileIsNotUnsplashFile(err) {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
if up != nil {
|
||||||
|
up.ID = 0
|
||||||
|
up.FileID = file.ID
|
||||||
|
if err := up.Save(s); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if err := SetProjectBackground(s, pd.Project.ID, file, pd.Project.BackgroundBlurHash); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
log.Debugf("Duplicated project background from project %d into %d", pd.ProjectID, pd.Project.ID)
|
||||||
|
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
func duplicateTasks(s *xorm.Session, doer web.Auth, ld *ProjectDuplicate, bucketMap map[int64]int64) (err error) {
|
func duplicateTasks(s *xorm.Session, doer web.Auth, ld *ProjectDuplicate, bucketMap map[int64]int64) (err error) {
|
||||||
// Get all tasks + all task details
|
// Get all tasks + all task details
|
||||||
tasks, _, _, err := getTasksForProjects(s, []*Project{{ID: ld.ProjectID}}, doer, &taskSearchOptions{})
|
tasks, _, _, err := getTasksForProjects(s, []*Project{{ID: ld.ProjectID}}, doer, &taskSearchOptions{})
|
||||||
|
|
|
@ -329,8 +329,7 @@ func TestProject_DeleteBackgroundFileIfExists(t *testing.T) {
|
||||||
err := SetProjectBackground(s, project.ID, file, "")
|
err := SetProjectBackground(s, project.ID, file, "")
|
||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
err = project.DeleteBackgroundFileIfExists()
|
err = project.DeleteBackgroundFileIfExists()
|
||||||
assert.Error(t, err)
|
assert.NoError(t, err)
|
||||||
assert.True(t, files.IsErrFileDoesNotExist(err))
|
|
||||||
})
|
})
|
||||||
t.Run("project without background", func(t *testing.T) {
|
t.Run("project without background", func(t *testing.T) {
|
||||||
db.LoadAndAssertFixtures(t)
|
db.LoadAndAssertFixtures(t)
|
||||||
|
|
|
@ -1083,6 +1083,7 @@ func recalculateTaskKanbanPositions(s *xorm.Session, bucketID int64) (err error)
|
||||||
|
|
||||||
_, err = s.Cols("kanban_position").
|
_, err = s.Cols("kanban_position").
|
||||||
Where("id = ?", task.ID).
|
Where("id = ?", task.ID).
|
||||||
|
NoAutoTime().
|
||||||
Update(&Task{KanbanPosition: currentPosition})
|
Update(&Task{KanbanPosition: currentPosition})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
|
@ -1111,6 +1112,7 @@ func recalculateTaskPositions(s *xorm.Session, projectID int64) (err error) {
|
||||||
|
|
||||||
_, err = s.Cols("position").
|
_, err = s.Cols("position").
|
||||||
Where("id = ?", task.ID).
|
Where("id = ?", task.ID).
|
||||||
|
NoAutoTime().
|
||||||
Update(&Task{Position: currentPosition})
|
Update(&Task{Position: currentPosition})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
|
|
|
@ -243,6 +243,12 @@ func ReindexAllTasks() (err error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func reindexTasks(s *xorm.Session, tasks map[int64]*Task) (err error) {
|
func reindexTasks(s *xorm.Session, tasks map[int64]*Task) (err error) {
|
||||||
|
|
||||||
|
if len(tasks) == 0 {
|
||||||
|
log.Infof("No tasks to index")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
err = addMoreInfoToTasks(s, tasks, &user.User{ID: 1})
|
err = addMoreInfoToTasks(s, tasks, &user.User{ID: 1})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("could not fetch more task info: %s", err.Error())
|
return fmt.Errorf("could not fetch more task info: %s", err.Error())
|
||||||
|
|
|
@ -291,11 +291,13 @@ func (p *Provider) Set(s *xorm.Session, image *background.Image, project *models
|
||||||
// Remove the old background if one exists
|
// Remove the old background if one exists
|
||||||
if project.BackgroundFileID != 0 {
|
if project.BackgroundFileID != 0 {
|
||||||
file := files.File{ID: project.BackgroundFileID}
|
file := files.File{ID: project.BackgroundFileID}
|
||||||
if err := file.Delete(); err != nil {
|
err = file.Delete()
|
||||||
|
if err != nil && !files.IsErrFileDoesNotExist(err) {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := models.RemoveUnsplashPhoto(s, project.BackgroundFileID); err != nil {
|
err = models.RemoveUnsplashPhoto(s, project.BackgroundFileID)
|
||||||
|
if err != nil && !files.IsErrFileDoesNotExist(err) {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -56,7 +56,8 @@ func (p *Provider) Set(s *xorm.Session, img *background.Image, project *models.P
|
||||||
// Remove the old background if one exists
|
// Remove the old background if one exists
|
||||||
if project.BackgroundFileID != 0 {
|
if project.BackgroundFileID != 0 {
|
||||||
file := files.File{ID: project.BackgroundFileID}
|
file := files.File{ID: project.BackgroundFileID}
|
||||||
if err := file.Delete(); err != nil {
|
err := file.Delete()
|
||||||
|
if err != nil && !files.IsErrFileDoesNotExist(err) {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -133,9 +133,7 @@ func (vcls *VikunjaCaldavProjectStorage) GetResourcesByList(rpaths []string) ([]
|
||||||
var uids []string
|
var uids []string
|
||||||
for _, path := range rpaths {
|
for _, path := range rpaths {
|
||||||
parts := strings.Split(path, "/")
|
parts := strings.Split(path, "/")
|
||||||
uid := []rune(parts[4]) // The 4th part is the id with ".ics" suffix
|
uids = append(uids, strings.TrimSuffix(parts[4], ".ics"))
|
||||||
endlen := len(uid) - len(".ics") // ".ics" are 4 bytes
|
|
||||||
uids = append(uids, string(uid[:endlen]))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
s := db.NewSession()
|
s := db.NewSession()
|
||||||
|
|
Loading…
Reference in New Issue