Backend: Replace export with temp directory #276
Signed-off-by: Michael Mayer <michael@liquidbytes.net>
This commit is contained in:
parent
2f5da21a5b
commit
b5ee4625a6
4 changed files with 16 additions and 3 deletions
|
@ -352,7 +352,7 @@ func DownloadAlbum(router *gin.RouterGroup, conf *config.Config) {
|
|||
return
|
||||
}
|
||||
|
||||
zipPath := path.Join(conf.ExportPath(), "album")
|
||||
zipPath := path.Join(conf.TempPath(), "album")
|
||||
zipToken := rnd.Token(3)
|
||||
zipBaseName := fmt.Sprintf("%s-%s.zip", strings.Title(a.AlbumSlug), zipToken)
|
||||
zipFileName := path.Join(zipPath, zipBaseName)
|
||||
|
|
|
@ -50,7 +50,7 @@ func CreateZip(router *gin.RouterGroup, conf *config.Config) {
|
|||
return
|
||||
}
|
||||
|
||||
zipPath := path.Join(conf.ExportPath(), "zip")
|
||||
zipPath := path.Join(conf.TempPath(), "zip")
|
||||
zipToken := rnd.Token(3)
|
||||
zipYear := time.Now().Format("January-2006")
|
||||
zipBaseName := fmt.Sprintf("Photos-%s-%s.zip", zipYear, zipToken)
|
||||
|
@ -105,7 +105,7 @@ func CreateZip(router *gin.RouterGroup, conf *config.Config) {
|
|||
func DownloadZip(router *gin.RouterGroup, conf *config.Config) {
|
||||
router.GET("/zip/:filename", func(c *gin.Context) {
|
||||
zipBaseName := filepath.Base(c.Param("filename"))
|
||||
zipPath := path.Join(conf.ExportPath(), "zip")
|
||||
zipPath := path.Join(conf.TempPath(), "zip")
|
||||
zipFileName := path.Join(zipPath, zipBaseName)
|
||||
|
||||
c.Header("Content-Disposition", fmt.Sprintf("attachment; filename=%s", zipBaseName))
|
||||
|
|
|
@ -13,6 +13,7 @@ import (
|
|||
"github.com/photoprism/photoprism/internal/entity"
|
||||
"github.com/photoprism/photoprism/internal/mutex"
|
||||
"github.com/photoprism/photoprism/internal/tidb"
|
||||
"github.com/sirupsen/logrus"
|
||||
)
|
||||
|
||||
// DatabaseDriver returns the database driver name.
|
||||
|
@ -156,10 +157,17 @@ func (c *Config) connectToDatabase(ctx context.Context) error {
|
|||
func (c *Config) DropTables() {
|
||||
db := c.Db()
|
||||
|
||||
log.SetLevel(logrus.FatalLevel)
|
||||
db.SetLogger(log)
|
||||
db.LogMode(false)
|
||||
|
||||
db.DropTableIfExists(
|
||||
&entity.Account{},
|
||||
&entity.File{},
|
||||
&entity.FileShare{},
|
||||
&entity.FileSync{},
|
||||
&entity.Photo{},
|
||||
&entity.Description{},
|
||||
&entity.Event{},
|
||||
&entity.Place{},
|
||||
&entity.Location{},
|
||||
|
|
|
@ -47,6 +47,7 @@ func NewTestParams() *Params {
|
|||
OriginalsPath: testDataPath + "/originals",
|
||||
ImportPath: testDataPath + "/import",
|
||||
ExportPath: testDataPath + "/export",
|
||||
TempPath: testDataPath + "/temp",
|
||||
DatabaseDriver: "mysql",
|
||||
DatabaseDsn: "photoprism:photoprism@tcp(photoprism-db:4001)/photoprism?parseTime=true",
|
||||
}
|
||||
|
@ -67,6 +68,7 @@ func NewTestParamsError() *Params {
|
|||
OriginalsPath: testDataPath + "/originals",
|
||||
ImportPath: testDataPath + "/import",
|
||||
ExportPath: testDataPath + "/export",
|
||||
TempPath: testDataPath + "/temp",
|
||||
DatabaseDriver: "mysql",
|
||||
DatabaseDsn: "photoprism:photoprism@tcp(photoprism-db:4001)/photoprism?parseTime=true",
|
||||
}
|
||||
|
@ -132,6 +134,7 @@ func CliTestContext() *cli.Context {
|
|||
globalSet.String("originals-path", config.OriginalsPath, "doc")
|
||||
globalSet.String("import-path", config.OriginalsPath, "doc")
|
||||
globalSet.String("export-path", config.OriginalsPath, "doc")
|
||||
globalSet.String("temp-path", config.OriginalsPath, "doc")
|
||||
globalSet.String("cache-path", config.OriginalsPath, "doc")
|
||||
globalSet.String("darktable-cli", config.DarktableBin, "doc")
|
||||
globalSet.Bool("detect-nsfw", config.DetectNSFW, "doc")
|
||||
|
@ -146,6 +149,7 @@ func CliTestContext() *cli.Context {
|
|||
c.Set("originals-path", config.OriginalsPath)
|
||||
c.Set("import-path", config.ImportPath)
|
||||
c.Set("export-path", config.ExportPath)
|
||||
c.Set("temp-path", config.TempPath)
|
||||
c.Set("cache-path", config.CachePath)
|
||||
c.Set("darktable-cli", config.DarktableBin)
|
||||
c.Set("detect-nsfw", "true")
|
||||
|
@ -157,6 +161,7 @@ func CliTestContext() *cli.Context {
|
|||
func (c *Config) RemoveTestData(t *testing.T) {
|
||||
os.RemoveAll(c.ImportPath())
|
||||
os.RemoveAll(c.ExportPath())
|
||||
os.RemoveAll(c.TempPath())
|
||||
os.RemoveAll(c.OriginalsPath())
|
||||
os.RemoveAll(c.CachePath())
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue