Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
canifa_note
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Vũ Hoàng Anh
canifa_note
Commits
4419b4d4
Unverified
Commit
4419b4d4
authored
Apr 03, 2023
by
boojack
Committed by
GitHub
Apr 03, 2023
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
chore: update version and remove isDev flag (#1452)
* chore: update version and remove isDev flag * chore: update
parent
1cab30f3
Changes
9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
49 additions
and
62 deletions
+49
-62
storage.go
api/storage.go
+7
-0
system_setting.go
api/system_setting.go
+1
-1
resource.go
server/resource.go
+13
-18
storage.go
server/storage.go
+1
-1
system.go
server/system.go
+1
-1
version.go
server/version/version.go
+1
-1
LATEST__SCHEMA.sql
store/db/migration/prod/LATEST__SCHEMA.sql
+4
-1
resource.go
store/resource.go
+18
-35
UpdateLocalStorageDialog.tsx
web/src/components/UpdateLocalStorageDialog.tsx
+3
-4
No files found.
api/storage.go
View file @
4419b4d4
package
api
package
api
const
(
// LocalStorage means the storage service is local file system.
LocalStorage
=
-
1
// DatabaseStorage means the storage service is database.
DatabaseStorage
=
0
)
type
StorageType
string
type
StorageType
string
const
(
const
(
...
...
api/system_setting.go
View file @
4419b4d4
...
@@ -140,7 +140,7 @@ func (upsert SystemSettingUpsert) Validate() error {
...
@@ -140,7 +140,7 @@ func (upsert SystemSettingUpsert) Validate() error {
return
fmt
.
Errorf
(
"invalid appearance value"
)
return
fmt
.
Errorf
(
"invalid appearance value"
)
}
}
}
else
if
upsert
.
Name
==
SystemSettingStorageServiceIDName
{
}
else
if
upsert
.
Name
==
SystemSettingStorageServiceIDName
{
value
:=
0
value
:=
DatabaseStorage
err
:=
json
.
Unmarshal
([]
byte
(
upsert
.
Value
),
&
value
)
err
:=
json
.
Unmarshal
([]
byte
(
upsert
.
Value
),
&
value
)
if
err
!=
nil
{
if
err
!=
nil
{
return
fmt
.
Errorf
(
"failed to unmarshal system setting storage service id value"
)
return
fmt
.
Errorf
(
"failed to unmarshal system setting storage service id value"
)
...
...
server/resource.go
View file @
4419b4d4
...
@@ -80,17 +80,17 @@ func (s *Server) registerResourceRoutes(g *echo.Group) {
...
@@ -80,17 +80,17 @@ func (s *Server) registerResourceRoutes(g *echo.Group) {
filename
:=
file
.
Filename
filename
:=
file
.
Filename
filetype
:=
file
.
Header
.
Get
(
"Content-Type"
)
filetype
:=
file
.
Header
.
Get
(
"Content-Type"
)
size
:=
file
.
Size
size
:=
file
.
Size
s
rc
,
err
:=
file
.
Open
()
s
ourceFile
,
err
:=
file
.
Open
()
if
err
!=
nil
{
if
err
!=
nil
{
return
echo
.
NewHTTPError
(
http
.
StatusInternalServerError
,
"Failed to open file"
)
.
SetInternal
(
err
)
return
echo
.
NewHTTPError
(
http
.
StatusInternalServerError
,
"Failed to open file"
)
.
SetInternal
(
err
)
}
}
defer
s
rc
.
Close
()
defer
s
ourceFile
.
Close
()
systemSettingStorageServiceID
,
err
:=
s
.
Store
.
FindSystemSetting
(
ctx
,
&
api
.
SystemSettingFind
{
Name
:
api
.
SystemSettingStorageServiceIDName
})
systemSettingStorageServiceID
,
err
:=
s
.
Store
.
FindSystemSetting
(
ctx
,
&
api
.
SystemSettingFind
{
Name
:
api
.
SystemSettingStorageServiceIDName
})
if
err
!=
nil
&&
common
.
ErrorCode
(
err
)
!=
common
.
NotFound
{
if
err
!=
nil
&&
common
.
ErrorCode
(
err
)
!=
common
.
NotFound
{
return
echo
.
NewHTTPError
(
http
.
StatusInternalServerError
,
"Failed to find storage"
)
.
SetInternal
(
err
)
return
echo
.
NewHTTPError
(
http
.
StatusInternalServerError
,
"Failed to find storage"
)
.
SetInternal
(
err
)
}
}
storageServiceID
:=
0
storageServiceID
:=
api
.
DatabaseStorage
if
systemSettingStorageServiceID
!=
nil
{
if
systemSettingStorageServiceID
!=
nil
{
err
=
json
.
Unmarshal
([]
byte
(
systemSettingStorageServiceID
.
Value
),
&
storageServiceID
)
err
=
json
.
Unmarshal
([]
byte
(
systemSettingStorageServiceID
.
Value
),
&
storageServiceID
)
if
err
!=
nil
{
if
err
!=
nil
{
...
@@ -99,9 +99,9 @@ func (s *Server) registerResourceRoutes(g *echo.Group) {
...
@@ -99,9 +99,9 @@ func (s *Server) registerResourceRoutes(g *echo.Group) {
}
}
var
resourceCreate
*
api
.
ResourceCreate
var
resourceCreate
*
api
.
ResourceCreate
if
storageServiceID
==
0
{
if
storageServiceID
==
api
.
DatabaseStorage
{
// Database storage.
// Database storage.
fileBytes
,
err
:=
io
.
ReadAll
(
s
rc
)
fileBytes
,
err
:=
io
.
ReadAll
(
s
ourceFile
)
if
err
!=
nil
{
if
err
!=
nil
{
return
echo
.
NewHTTPError
(
http
.
StatusInternalServerError
,
"Failed to read file"
)
.
SetInternal
(
err
)
return
echo
.
NewHTTPError
(
http
.
StatusInternalServerError
,
"Failed to read file"
)
.
SetInternal
(
err
)
}
}
...
@@ -112,17 +112,17 @@ func (s *Server) registerResourceRoutes(g *echo.Group) {
...
@@ -112,17 +112,17 @@ func (s *Server) registerResourceRoutes(g *echo.Group) {
Size
:
size
,
Size
:
size
,
Blob
:
fileBytes
,
Blob
:
fileBytes
,
}
}
}
else
if
storageServiceID
==
-
1
{
}
else
if
storageServiceID
==
api
.
LocalStorage
{
// Local storage.
// Local storage.
systemSettingLocalStoragePath
,
err
:=
s
.
Store
.
FindSystemSetting
(
ctx
,
&
api
.
SystemSettingFind
{
Name
:
api
.
SystemSettingLocalStoragePathName
})
systemSettingLocalStoragePath
,
err
:=
s
.
Store
.
FindSystemSetting
(
ctx
,
&
api
.
SystemSettingFind
{
Name
:
api
.
SystemSettingLocalStoragePathName
})
if
err
!=
nil
&&
common
.
ErrorCode
(
err
)
!=
common
.
NotFound
{
if
err
!=
nil
&&
common
.
ErrorCode
(
err
)
!=
common
.
NotFound
{
return
echo
.
NewHTTPError
(
http
.
StatusInternalServerError
,
"Failed to find
storage
"
)
.
SetInternal
(
err
)
return
echo
.
NewHTTPError
(
http
.
StatusInternalServerError
,
"Failed to find
local storage path setting
"
)
.
SetInternal
(
err
)
}
}
localStoragePath
:=
""
localStoragePath
:=
""
if
systemSettingLocalStoragePath
!=
nil
{
if
systemSettingLocalStoragePath
!=
nil
{
err
=
json
.
Unmarshal
([]
byte
(
systemSettingLocalStoragePath
.
Value
),
&
localStoragePath
)
err
=
json
.
Unmarshal
([]
byte
(
systemSettingLocalStoragePath
.
Value
),
&
localStoragePath
)
if
err
!=
nil
{
if
err
!=
nil
{
return
echo
.
NewHTTPError
(
http
.
StatusInternalServerError
,
"Failed to unmarshal
storage service id
"
)
.
SetInternal
(
err
)
return
echo
.
NewHTTPError
(
http
.
StatusInternalServerError
,
"Failed to unmarshal
local storage path setting
"
)
.
SetInternal
(
err
)
}
}
}
}
filePath
:=
localStoragePath
filePath
:=
localStoragePath
...
@@ -131,8 +131,7 @@ func (s *Server) registerResourceRoutes(g *echo.Group) {
...
@@ -131,8 +131,7 @@ func (s *Server) registerResourceRoutes(g *echo.Group) {
}
}
filePath
=
path
.
Join
(
s
.
Profile
.
Data
,
replacePathTemplate
(
filePath
,
filename
))
filePath
=
path
.
Join
(
s
.
Profile
.
Data
,
replacePathTemplate
(
filePath
,
filename
))
dirPath
:=
filepath
.
Dir
(
filePath
)
dirPath
:=
filepath
.
Dir
(
filePath
)
err
=
os
.
MkdirAll
(
dirPath
,
os
.
ModePerm
)
if
err
=
os
.
MkdirAll
(
dirPath
,
os
.
ModePerm
);
err
!=
nil
{
if
err
!=
nil
{
return
echo
.
NewHTTPError
(
http
.
StatusInternalServerError
,
"Failed to create directory"
)
.
SetInternal
(
err
)
return
echo
.
NewHTTPError
(
http
.
StatusInternalServerError
,
"Failed to create directory"
)
.
SetInternal
(
err
)
}
}
dst
,
err
:=
os
.
Create
(
filePath
)
dst
,
err
:=
os
.
Create
(
filePath
)
...
@@ -140,8 +139,7 @@ func (s *Server) registerResourceRoutes(g *echo.Group) {
...
@@ -140,8 +139,7 @@ func (s *Server) registerResourceRoutes(g *echo.Group) {
return
echo
.
NewHTTPError
(
http
.
StatusInternalServerError
,
"Failed to create file"
)
.
SetInternal
(
err
)
return
echo
.
NewHTTPError
(
http
.
StatusInternalServerError
,
"Failed to create file"
)
.
SetInternal
(
err
)
}
}
defer
dst
.
Close
()
defer
dst
.
Close
()
_
,
err
=
io
.
Copy
(
dst
,
sourceFile
)
_
,
err
=
io
.
Copy
(
dst
,
src
)
if
err
!=
nil
{
if
err
!=
nil
{
return
echo
.
NewHTTPError
(
http
.
StatusInternalServerError
,
"Failed to copy file"
)
.
SetInternal
(
err
)
return
echo
.
NewHTTPError
(
http
.
StatusInternalServerError
,
"Failed to copy file"
)
.
SetInternal
(
err
)
}
}
...
@@ -179,7 +177,7 @@ func (s *Server) registerResourceRoutes(g *echo.Group) {
...
@@ -179,7 +177,7 @@ func (s *Server) registerResourceRoutes(g *echo.Group) {
return
echo
.
NewHTTPError
(
http
.
StatusInternalServerError
,
"Failed to new s3 client"
)
.
SetInternal
(
err
)
return
echo
.
NewHTTPError
(
http
.
StatusInternalServerError
,
"Failed to new s3 client"
)
.
SetInternal
(
err
)
}
}
link
,
err
:=
s3client
.
UploadFile
(
ctx
,
s3FileKey
,
filetype
,
s
rc
)
link
,
err
:=
s3client
.
UploadFile
(
ctx
,
s3FileKey
,
filetype
,
s
ourceFile
)
if
err
!=
nil
{
if
err
!=
nil
{
return
echo
.
NewHTTPError
(
http
.
StatusInternalServerError
,
"Failed to upload via s3 client"
)
.
SetInternal
(
err
)
return
echo
.
NewHTTPError
(
http
.
StatusInternalServerError
,
"Failed to upload via s3 client"
)
.
SetInternal
(
err
)
}
}
...
@@ -194,11 +192,8 @@ func (s *Server) registerResourceRoutes(g *echo.Group) {
...
@@ -194,11 +192,8 @@ func (s *Server) registerResourceRoutes(g *echo.Group) {
}
}
}
}
if
s
.
Profile
.
IsDev
()
{
publicID
:=
common
.
GenUUID
()
publicID
:=
common
.
GenUUID
()
resourceCreate
.
PublicID
=
publicID
resourceCreate
.
PublicID
=
publicID
}
resource
,
err
:=
s
.
Store
.
CreateResource
(
ctx
,
resourceCreate
)
resource
,
err
:=
s
.
Store
.
CreateResource
(
ctx
,
resourceCreate
)
if
err
!=
nil
{
if
err
!=
nil
{
return
echo
.
NewHTTPError
(
http
.
StatusInternalServerError
,
"Failed to create resource"
)
.
SetInternal
(
err
)
return
echo
.
NewHTTPError
(
http
.
StatusInternalServerError
,
"Failed to create resource"
)
.
SetInternal
(
err
)
...
...
server/storage.go
View file @
4419b4d4
...
@@ -129,7 +129,7 @@ func (s *Server) registerStorageRoutes(g *echo.Group) {
...
@@ -129,7 +129,7 @@ func (s *Server) registerStorageRoutes(g *echo.Group) {
return
echo
.
NewHTTPError
(
http
.
StatusInternalServerError
,
"Failed to find storage"
)
.
SetInternal
(
err
)
return
echo
.
NewHTTPError
(
http
.
StatusInternalServerError
,
"Failed to find storage"
)
.
SetInternal
(
err
)
}
}
if
systemSetting
!=
nil
{
if
systemSetting
!=
nil
{
storageServiceID
:=
0
storageServiceID
:=
api
.
DatabaseStorage
err
=
json
.
Unmarshal
([]
byte
(
systemSetting
.
Value
),
&
storageServiceID
)
err
=
json
.
Unmarshal
([]
byte
(
systemSetting
.
Value
),
&
storageServiceID
)
if
err
!=
nil
{
if
err
!=
nil
{
return
echo
.
NewHTTPError
(
http
.
StatusInternalServerError
,
"Failed to unmarshal storage service id"
)
.
SetInternal
(
err
)
return
echo
.
NewHTTPError
(
http
.
StatusInternalServerError
,
"Failed to unmarshal storage service id"
)
.
SetInternal
(
err
)
...
...
server/system.go
View file @
4419b4d4
...
@@ -51,7 +51,7 @@ func (s *Server) registerSystemRoutes(g *echo.Group) {
...
@@ -51,7 +51,7 @@ func (s *Server) registerSystemRoutes(g *echo.Group) {
Appearance
:
"system"
,
Appearance
:
"system"
,
ExternalURL
:
""
,
ExternalURL
:
""
,
},
},
StorageServiceID
:
0
,
StorageServiceID
:
api
.
DatabaseStorage
,
LocalStoragePath
:
""
,
LocalStoragePath
:
""
,
}
}
...
...
server/version/version.go
View file @
4419b4d4
...
@@ -9,7 +9,7 @@ import (
...
@@ -9,7 +9,7 @@ import (
// Version is the service current released version.
// Version is the service current released version.
// Semantic versioning: https://semver.org/
// Semantic versioning: https://semver.org/
var
Version
=
"0.1
1.2
"
var
Version
=
"0.1
2.0
"
// DevVersion is the service current development version.
// DevVersion is the service current development version.
var
DevVersion
=
"0.12.0"
var
DevVersion
=
"0.12.0"
...
...
store/db/migration/prod/LATEST__SCHEMA.sql
View file @
4419b4d4
...
@@ -76,7 +76,10 @@ CREATE TABLE resource (
...
@@ -76,7 +76,10 @@ CREATE TABLE resource (
blob
BLOB
DEFAULT
NULL
,
blob
BLOB
DEFAULT
NULL
,
external_link
TEXT
NOT
NULL
DEFAULT
''
,
external_link
TEXT
NOT
NULL
DEFAULT
''
,
type
TEXT
NOT
NULL
DEFAULT
''
,
type
TEXT
NOT
NULL
DEFAULT
''
,
size
INTEGER
NOT
NULL
DEFAULT
0
size
INTEGER
NOT
NULL
DEFAULT
0
,
internal_path
TEXT
NOT
NULL
DEFAULT
''
,
public_id
TEXT
NOT
NULL
DEFAULT
''
,
UNIQUE
(
id
,
public_id
)
);
);
-- memo_resource
-- memo_resource
...
...
store/resource.go
View file @
4419b4d4
...
@@ -94,7 +94,7 @@ func (s *Store) CreateResource(ctx context.Context, create *api.ResourceCreate)
...
@@ -94,7 +94,7 @@ func (s *Store) CreateResource(ctx context.Context, create *api.ResourceCreate)
}
}
defer
tx
.
Rollback
()
defer
tx
.
Rollback
()
resourceRaw
,
err
:=
s
.
createResourceImpl
(
ctx
,
tx
,
create
)
resourceRaw
,
err
:=
createResourceImpl
(
ctx
,
tx
,
create
)
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
err
return
nil
,
err
}
}
...
@@ -115,7 +115,7 @@ func (s *Store) FindResourceList(ctx context.Context, find *api.ResourceFind) ([
...
@@ -115,7 +115,7 @@ func (s *Store) FindResourceList(ctx context.Context, find *api.ResourceFind) ([
}
}
defer
tx
.
Rollback
()
defer
tx
.
Rollback
()
resourceRawList
,
err
:=
s
.
findResourceListImpl
(
ctx
,
tx
,
find
)
resourceRawList
,
err
:=
findResourceListImpl
(
ctx
,
tx
,
find
)
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
err
return
nil
,
err
}
}
...
@@ -135,7 +135,7 @@ func (s *Store) FindResource(ctx context.Context, find *api.ResourceFind) (*api.
...
@@ -135,7 +135,7 @@ func (s *Store) FindResource(ctx context.Context, find *api.ResourceFind) (*api.
}
}
defer
tx
.
Rollback
()
defer
tx
.
Rollback
()
list
,
err
:=
s
.
findResourceListImpl
(
ctx
,
tx
,
find
)
list
,
err
:=
findResourceListImpl
(
ctx
,
tx
,
find
)
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
err
return
nil
,
err
}
}
...
@@ -178,7 +178,7 @@ func (s *Store) PatchResource(ctx context.Context, patch *api.ResourcePatch) (*a
...
@@ -178,7 +178,7 @@ func (s *Store) PatchResource(ctx context.Context, patch *api.ResourcePatch) (*a
}
}
defer
tx
.
Rollback
()
defer
tx
.
Rollback
()
resourceRaw
,
err
:=
s
.
patchResourceImpl
(
ctx
,
tx
,
patch
)
resourceRaw
,
err
:=
patchResourceImpl
(
ctx
,
tx
,
patch
)
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
err
return
nil
,
err
}
}
...
@@ -192,16 +192,10 @@ func (s *Store) PatchResource(ctx context.Context, patch *api.ResourcePatch) (*a
...
@@ -192,16 +192,10 @@ func (s *Store) PatchResource(ctx context.Context, patch *api.ResourcePatch) (*a
return
resource
,
nil
return
resource
,
nil
}
}
func
(
s
*
Store
)
createResourceImpl
(
ctx
context
.
Context
,
tx
*
sql
.
Tx
,
create
*
api
.
ResourceCreate
)
(
*
resourceRaw
,
error
)
{
func
createResourceImpl
(
ctx
context
.
Context
,
tx
*
sql
.
Tx
,
create
*
api
.
ResourceCreate
)
(
*
resourceRaw
,
error
)
{
fields
:=
[]
string
{
"filename"
,
"blob"
,
"external_link"
,
"type"
,
"size"
,
"creator_id"
}
fields
:=
[]
string
{
"filename"
,
"blob"
,
"external_link"
,
"type"
,
"size"
,
"creator_id"
,
"internal_path"
,
"public_id"
}
values
:=
[]
any
{
create
.
Filename
,
create
.
Blob
,
create
.
ExternalLink
,
create
.
Type
,
create
.
Size
,
create
.
CreatorID
}
values
:=
[]
any
{
create
.
Filename
,
create
.
Blob
,
create
.
ExternalLink
,
create
.
Type
,
create
.
Size
,
create
.
CreatorID
,
create
.
InternalPath
,
create
.
PublicID
}
placeholders
:=
[]
string
{
"?"
,
"?"
,
"?"
,
"?"
,
"?"
,
"?"
}
placeholders
:=
[]
string
{
"?"
,
"?"
,
"?"
,
"?"
,
"?"
,
"?"
,
"?"
,
"?"
}
if
s
.
profile
.
IsDev
()
{
fields
=
append
(
fields
,
"internal_path"
,
"public_id"
)
values
=
append
(
values
,
create
.
InternalPath
,
create
.
PublicID
)
placeholders
=
append
(
placeholders
,
"?"
,
"?"
)
}
query
:=
`
query
:=
`
INSERT INTO resource (
INSERT INTO resource (
`
+
strings
.
Join
(
fields
,
","
)
+
`
`
+
strings
.
Join
(
fields
,
","
)
+
`
...
@@ -218,9 +212,8 @@ func (s *Store) createResourceImpl(ctx context.Context, tx *sql.Tx, create *api.
...
@@ -218,9 +212,8 @@ func (s *Store) createResourceImpl(ctx context.Context, tx *sql.Tx, create *api.
&
resourceRaw
.
Type
,
&
resourceRaw
.
Type
,
&
resourceRaw
.
Size
,
&
resourceRaw
.
Size
,
&
resourceRaw
.
CreatorID
,
&
resourceRaw
.
CreatorID
,
}
&
resourceRaw
.
InternalPath
,
if
s
.
profile
.
IsDev
()
{
&
resourceRaw
.
PublicID
,
dests
=
append
(
dests
,
&
resourceRaw
.
InternalPath
,
&
resourceRaw
.
PublicID
)
}
}
dests
=
append
(
dests
,
[]
any
{
&
resourceRaw
.
CreatedTs
,
&
resourceRaw
.
UpdatedTs
}
...
)
dests
=
append
(
dests
,
[]
any
{
&
resourceRaw
.
CreatedTs
,
&
resourceRaw
.
UpdatedTs
}
...
)
if
err
:=
tx
.
QueryRowContext
(
ctx
,
query
,
values
...
)
.
Scan
(
dests
...
);
err
!=
nil
{
if
err
:=
tx
.
QueryRowContext
(
ctx
,
query
,
values
...
)
.
Scan
(
dests
...
);
err
!=
nil
{
...
@@ -230,7 +223,7 @@ func (s *Store) createResourceImpl(ctx context.Context, tx *sql.Tx, create *api.
...
@@ -230,7 +223,7 @@ func (s *Store) createResourceImpl(ctx context.Context, tx *sql.Tx, create *api.
return
&
resourceRaw
,
nil
return
&
resourceRaw
,
nil
}
}
func
(
s
*
Store
)
patchResourceImpl
(
ctx
context
.
Context
,
tx
*
sql
.
Tx
,
patch
*
api
.
ResourcePatch
)
(
*
resourceRaw
,
error
)
{
func
patchResourceImpl
(
ctx
context
.
Context
,
tx
*
sql
.
Tx
,
patch
*
api
.
ResourcePatch
)
(
*
resourceRaw
,
error
)
{
set
,
args
:=
[]
string
{},
[]
any
{}
set
,
args
:=
[]
string
{},
[]
any
{}
if
v
:=
patch
.
UpdatedTs
;
v
!=
nil
{
if
v
:=
patch
.
UpdatedTs
;
v
!=
nil
{
...
@@ -244,12 +237,7 @@ func (s *Store) patchResourceImpl(ctx context.Context, tx *sql.Tx, patch *api.Re
...
@@ -244,12 +237,7 @@ func (s *Store) patchResourceImpl(ctx context.Context, tx *sql.Tx, patch *api.Re
}
}
args
=
append
(
args
,
patch
.
ID
)
args
=
append
(
args
,
patch
.
ID
)
fields
:=
[]
string
{
"id"
,
"filename"
,
"external_link"
,
"type"
,
"size"
,
"creator_id"
,
"created_ts"
,
"updated_ts"
,
"internal_path"
,
"public_id"
}
fields
:=
[]
string
{
"id"
,
"filename"
,
"external_link"
,
"type"
,
"size"
,
"creator_id"
,
"created_ts"
,
"updated_ts"
}
if
s
.
profile
.
IsDev
()
{
fields
=
append
(
fields
,
"internal_path"
,
"public_id"
)
}
query
:=
`
query
:=
`
UPDATE resource
UPDATE resource
SET `
+
strings
.
Join
(
set
,
", "
)
+
`
SET `
+
strings
.
Join
(
set
,
", "
)
+
`
...
@@ -265,9 +253,8 @@ func (s *Store) patchResourceImpl(ctx context.Context, tx *sql.Tx, patch *api.Re
...
@@ -265,9 +253,8 @@ func (s *Store) patchResourceImpl(ctx context.Context, tx *sql.Tx, patch *api.Re
&
resourceRaw
.
CreatorID
,
&
resourceRaw
.
CreatorID
,
&
resourceRaw
.
CreatedTs
,
&
resourceRaw
.
CreatedTs
,
&
resourceRaw
.
UpdatedTs
,
&
resourceRaw
.
UpdatedTs
,
}
&
resourceRaw
.
InternalPath
,
if
s
.
profile
.
IsDev
()
{
&
resourceRaw
.
PublicID
,
dests
=
append
(
dests
,
&
resourceRaw
.
InternalPath
,
&
resourceRaw
.
PublicID
)
}
}
if
err
:=
tx
.
QueryRowContext
(
ctx
,
query
,
args
...
)
.
Scan
(
dests
...
);
err
!=
nil
{
if
err
:=
tx
.
QueryRowContext
(
ctx
,
query
,
args
...
)
.
Scan
(
dests
...
);
err
!=
nil
{
return
nil
,
FormatError
(
err
)
return
nil
,
FormatError
(
err
)
...
@@ -276,7 +263,7 @@ func (s *Store) patchResourceImpl(ctx context.Context, tx *sql.Tx, patch *api.Re
...
@@ -276,7 +263,7 @@ func (s *Store) patchResourceImpl(ctx context.Context, tx *sql.Tx, patch *api.Re
return
&
resourceRaw
,
nil
return
&
resourceRaw
,
nil
}
}
func
(
s
*
Store
)
findResourceListImpl
(
ctx
context
.
Context
,
tx
*
sql
.
Tx
,
find
*
api
.
ResourceFind
)
([]
*
resourceRaw
,
error
)
{
func
findResourceListImpl
(
ctx
context
.
Context
,
tx
*
sql
.
Tx
,
find
*
api
.
ResourceFind
)
([]
*
resourceRaw
,
error
)
{
where
,
args
:=
[]
string
{
"1 = 1"
},
[]
any
{}
where
,
args
:=
[]
string
{
"1 = 1"
},
[]
any
{}
if
v
:=
find
.
ID
;
v
!=
nil
{
if
v
:=
find
.
ID
;
v
!=
nil
{
...
@@ -295,13 +282,10 @@ func (s *Store) findResourceListImpl(ctx context.Context, tx *sql.Tx, find *api.
...
@@ -295,13 +282,10 @@ func (s *Store) findResourceListImpl(ctx context.Context, tx *sql.Tx, find *api.
where
,
args
=
append
(
where
,
"resource.public_id = ?"
),
append
(
args
,
*
v
)
where
,
args
=
append
(
where
,
"resource.public_id = ?"
),
append
(
args
,
*
v
)
}
}
fields
:=
[]
string
{
"resource.id"
,
"resource.filename"
,
"resource.external_link"
,
"resource.type"
,
"resource.size"
,
"resource.creator_id"
,
"resource.created_ts"
,
"resource.updated_ts"
}
fields
:=
[]
string
{
"resource.id"
,
"resource.filename"
,
"resource.external_link"
,
"resource.type"
,
"resource.size"
,
"resource.creator_id"
,
"resource.created_ts"
,
"resource.updated_ts"
,
"internal_path"
,
"public_id"
}
if
find
.
GetBlob
{
if
find
.
GetBlob
{
fields
=
append
(
fields
,
"resource.blob"
)
fields
=
append
(
fields
,
"resource.blob"
)
}
}
if
s
.
profile
.
IsDev
()
{
fields
=
append
(
fields
,
"internal_path"
,
"public_id"
)
}
query
:=
fmt
.
Sprintf
(
`
query
:=
fmt
.
Sprintf
(
`
SELECT
SELECT
...
@@ -339,13 +323,12 @@ func (s *Store) findResourceListImpl(ctx context.Context, tx *sql.Tx, find *api.
...
@@ -339,13 +323,12 @@ func (s *Store) findResourceListImpl(ctx context.Context, tx *sql.Tx, find *api.
&
resourceRaw
.
CreatorID
,
&
resourceRaw
.
CreatorID
,
&
resourceRaw
.
CreatedTs
,
&
resourceRaw
.
CreatedTs
,
&
resourceRaw
.
UpdatedTs
,
&
resourceRaw
.
UpdatedTs
,
&
resourceRaw
.
InternalPath
,
&
resourceRaw
.
PublicID
,
}
}
if
find
.
GetBlob
{
if
find
.
GetBlob
{
dests
=
append
(
dests
,
&
resourceRaw
.
Blob
)
dests
=
append
(
dests
,
&
resourceRaw
.
Blob
)
}
}
if
s
.
profile
.
IsDev
()
{
dests
=
append
(
dests
,
&
resourceRaw
.
InternalPath
,
&
resourceRaw
.
PublicID
)
}
if
err
:=
rows
.
Scan
(
dests
...
);
err
!=
nil
{
if
err
:=
rows
.
Scan
(
dests
...
);
err
!=
nil
{
return
nil
,
FormatError
(
err
)
return
nil
,
FormatError
(
err
)
}
}
...
...
web/src/components/UpdateLocalStorageDialog.tsx
View file @
4419b4d4
...
@@ -48,11 +48,10 @@ const UpdateLocalStorageDialog: React.FC<Props> = (props: Props) => {
...
@@ -48,11 +48,10 @@ const UpdateLocalStorageDialog: React.FC<Props> = (props: Props) => {
<
div
className=
"dialog-content-container"
>
<
div
className=
"dialog-content-container"
>
<
div
className=
"py-2"
>
<
div
className=
"py-2"
>
<
Typography
className=
"!mb-1"
level=
"body2"
>
<
Typography
className=
"!mb-1"
level=
"body2"
>
Local Path
Local path
</
Typography
>
<
Typography
className=
"!mb-1"
level=
"body2"
>
<
span
className=
"text-sm text-gray-400 ml-1"
>
{
"e.g., {year}/{month}/{day}/your/path/{timestamp}_{filename}"
}
</
span
>
</
Typography
>
</
Typography
>
<
p
className=
"text-sm text-gray-400 break-all"
>
{
"It's a relative path to your database file."
}
</
p
>
<
p
className=
"text-sm text-gray-400 mb-2 break-all"
>
{
"e.g. assets/{timestamp}_{filename}"
}
</
p
>
<
Input
className=
"mb-2"
placeholder=
"Path"
value=
{
path
}
onChange=
{
(
e
)
=>
setPath
(
e
.
target
.
value
)
}
fullWidth
/>
<
Input
className=
"mb-2"
placeholder=
"Path"
value=
{
path
}
onChange=
{
(
e
)
=>
setPath
(
e
.
target
.
value
)
}
fullWidth
/>
</
div
>
</
div
>
<
div
className=
"mt-2 w-full flex flex-row justify-end items-center space-x-1"
>
<
div
className=
"mt-2 w-full flex flex-row justify-end items-center space-x-1"
>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment