Compare commits

..

No commits in common. "4f55099896ef6b0d69828abed2b7118432a72495" and "bfcefa0217ce321136bedf07df09dc4a1aab2636" have entirely different histories.

14 changed files with 55 additions and 84 deletions

View File

@ -438,7 +438,6 @@ steps:
# 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.
GOPATH: /srv/app
GOPROXY: https://goproxy.kolaente.de
commands:
- export PATH=$PATH:$GOPATH/bin
- go install github.com/magefile/mage
@ -452,7 +451,6 @@ steps:
# 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.
GOPATH: /srv/app
GOPROXY: https://goproxy.kolaente.de
commands:
- export PATH=$PATH:$GOPATH/bin
- go install github.com/magefile/mage
@ -466,7 +464,6 @@ steps:
# 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.
GOPATH: /srv/app
GOPROXY: https://goproxy.kolaente.de
commands:
- export PATH=$PATH:$GOPATH/bin
- go install github.com/magefile/mage
@ -778,6 +775,6 @@ steps:
- failure
---
kind: signature
hmac: 6bc74f5b7e9c51e725100e05f07cdac656d6c3d49d19c2b112aed812c86e7a9a
hmac: b32ea5780ab6c4e57f201ec468357340349591a3026c96efd669a0b9c10f0e34
...

View File

@ -13,7 +13,6 @@ COPY . ./
ARG TARGETOS TARGETARCH TARGETVARIANT
ENV GOPROXY https://goproxy.kolaente.de
RUN export PATH=$PATH:$GOPATH/bin && \
mage build:clean && \
mage release:xgo "${TARGETOS}/${TARGETARCH}/${TARGETVARIANT}"

View File

@ -453,6 +453,9 @@ func (Build) Clean() error {
if err := os.RemoveAll(BinLocation); err != nil && !os.IsNotExist(err) {
return err
}
if err := os.RemoveAll(swaggerDocsFolderLocation); err != nil && !os.IsNotExist(err) {
return err
}
return nil
}

View File

@ -17,13 +17,13 @@
package caldav
import (
"code.vikunja.io/api/pkg/db"
"errors"
"strconv"
"strings"
"time"
"code.vikunja.io/api/pkg/config"
"code.vikunja.io/api/pkg/db"
"code.vikunja.io/api/pkg/log"
"code.vikunja.io/api/pkg/models"
"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
task := make(map[string]ics.IANAProperty)
var relation ics.IANAProperty
var relation *ics.IANAProperty
for _, c := range vTodo.UnknownPropertiesIANAProperties() {
task[c.IANAToken] = c
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"]),
}
if relation.Value != "" {
if relation != nil {
s := db.NewSession()
defer s.Close()

View File

@ -38,7 +38,7 @@ func init() {
ID: "20230828125443",
Description: "",
Migrate: func(tx *xorm.Engine) error {
return tx.CreateTables(typesenseSync20230828125443{})
return tx.Sync2(typesenseSync20230828125443{})
},
Rollback: func(tx *xorm.Engine) error {
return nil

View File

@ -59,7 +59,6 @@ func GetTables() []interface{} {
&Subscription{},
&Favorite{},
&APIToken{},
&TypesenseSync{},
}
}

View File

@ -1030,12 +1030,7 @@ func (p *Project) DeleteBackgroundFileIfExists() (err error) {
}
file := files.File{ID: p.BackgroundFileID}
err = file.Delete()
if err != nil && files.IsErrFileDoesNotExist(err) {
return nil
}
return err
return file.Delete()
}
// SetProjectBackground sets a background file as project background in the db

View File

@ -118,9 +118,43 @@ func (pd *ProjectDuplicate) Create(s *xorm.Session, doer web.Auth) (err error) {
return
}
err = duplicateProjectBackground(s, pd, doer)
if err != nil {
return
// Background files + unsplash info
if pd.Project.BackgroundFileID != 0 {
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
@ -173,54 +207,6 @@ func (pd *ProjectDuplicate) Create(s *xorm.Session, doer web.Auth) (err error) {
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) {
// Get all tasks + all task details
tasks, _, _, err := getTasksForProjects(s, []*Project{{ID: ld.ProjectID}}, doer, &taskSearchOptions{})

View File

@ -329,7 +329,8 @@ func TestProject_DeleteBackgroundFileIfExists(t *testing.T) {
err := SetProjectBackground(s, project.ID, file, "")
assert.NoError(t, err)
err = project.DeleteBackgroundFileIfExists()
assert.NoError(t, err)
assert.Error(t, err)
assert.True(t, files.IsErrFileDoesNotExist(err))
})
t.Run("project without background", func(t *testing.T) {
db.LoadAndAssertFixtures(t)

View File

@ -1083,7 +1083,6 @@ func recalculateTaskKanbanPositions(s *xorm.Session, bucketID int64) (err error)
_, err = s.Cols("kanban_position").
Where("id = ?", task.ID).
NoAutoTime().
Update(&Task{KanbanPosition: currentPosition})
if err != nil {
return
@ -1112,7 +1111,6 @@ func recalculateTaskPositions(s *xorm.Session, projectID int64) (err error) {
_, err = s.Cols("position").
Where("id = ?", task.ID).
NoAutoTime().
Update(&Task{Position: currentPosition})
if err != nil {
return

View File

@ -243,12 +243,6 @@ func ReindexAllTasks() (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})
if err != nil {
return fmt.Errorf("could not fetch more task info: %s", err.Error())

View File

@ -291,13 +291,11 @@ func (p *Provider) Set(s *xorm.Session, image *background.Image, project *models
// Remove the old background if one exists
if project.BackgroundFileID != 0 {
file := files.File{ID: project.BackgroundFileID}
err = file.Delete()
if err != nil && !files.IsErrFileDoesNotExist(err) {
if err := file.Delete(); err != nil {
return err
}
err = models.RemoveUnsplashPhoto(s, project.BackgroundFileID)
if err != nil && !files.IsErrFileDoesNotExist(err) {
if err := models.RemoveUnsplashPhoto(s, project.BackgroundFileID); err != nil {
return err
}
}

View File

@ -56,8 +56,7 @@ func (p *Provider) Set(s *xorm.Session, img *background.Image, project *models.P
// Remove the old background if one exists
if project.BackgroundFileID != 0 {
file := files.File{ID: project.BackgroundFileID}
err := file.Delete()
if err != nil && !files.IsErrFileDoesNotExist(err) {
if err := file.Delete(); err != nil {
return err
}
}

View File

@ -133,7 +133,9 @@ func (vcls *VikunjaCaldavProjectStorage) GetResourcesByList(rpaths []string) ([]
var uids []string
for _, path := range rpaths {
parts := strings.Split(path, "/")
uids = append(uids, strings.TrimSuffix(parts[4], ".ics"))
uid := []rune(parts[4]) // The 4th part is the id with ".ics" suffix
endlen := len(uid) - len(".ics") // ".ics" are 4 bytes
uids = append(uids, string(uid[:endlen]))
}
s := db.NewSession()