Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
tank
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Container Registry
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
AURA
tank
Commits
3fff558c
Commit
3fff558c
authored
6 years ago
by
Christian Pointner
Browse files
Options
Downloads
Patches
Plain Diff
implemented PATCH file, aka update metadata
parent
6bf44bc4
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
api/v1/api_files.go
+18
-1
18 additions, 1 deletion
api/v1/api_files.go
cmd/tank/bindata_assetfs.go
+10
-10
10 additions, 10 deletions
cmd/tank/bindata_assetfs.go
store/files.go
+14
-0
14 additions, 0 deletions
store/files.go
with
42 additions
and
11 deletions
api/v1/api_files.go
+
18
−
1
View file @
3fff558c
...
@@ -88,7 +88,24 @@ func (api *API) ReadFileOfGroup() http.Handler {
...
@@ -88,7 +88,24 @@ func (api *API) ReadFileOfGroup() http.Handler {
func
(
api
*
API
)
PatchFileOfGroup
()
http
.
Handler
{
func
(
api
*
API
)
PatchFileOfGroup
()
http
.
Handler
{
return
http
.
HandlerFunc
(
func
(
w
http
.
ResponseWriter
,
r
*
http
.
Request
)
{
return
http
.
HandlerFunc
(
func
(
w
http
.
ResponseWriter
,
r
*
http
.
Request
)
{
sendWebResponse
(
w
,
http
.
StatusNotImplemented
,
ErrorResponse
{
Error
:
"patching files of group not yet implemented"
})
vars
:=
mux
.
Vars
(
r
)
id
,
err
:=
idFromString
(
vars
[
"file-id"
])
if
err
!=
nil
{
sendWebResponse
(
w
,
http
.
StatusBadRequest
,
ErrorResponse
{
Error
:
"invalid file-id: "
+
err
.
Error
()})
return
}
data
:=
make
(
map
[
string
]
interface
{})
if
err
=
json
.
NewDecoder
(
r
.
Body
)
.
Decode
(
&
data
);
err
!=
nil
{
sendWebResponse
(
w
,
http
.
StatusBadRequest
,
ErrorResponse
{
Error
:
"error decoding request: "
+
err
.
Error
()})
return
}
// TODO: warn if data contains invalid/unknown keys
file
,
err
:=
api
.
store
.
UpdateFileMetadata
(
vars
[
"group-id"
],
id
,
data
)
if
err
!=
nil
{
sendStoreError
(
w
,
err
)
return
}
sendWebResponse
(
w
,
http
.
StatusOK
,
file
)
})
})
}
}
...
...
This diff is collapsed.
Click to expand it.
cmd/tank/bindata_assetfs.go
+
10
−
10
View file @
3fff558c
...
@@ -93,7 +93,7 @@ func uiIndexHtml() (*asset, error) {
...
@@ -93,7 +93,7 @@ func uiIndexHtml() (*asset, error) {
return nil, err
return nil, err
}
}
info := bindataFileInfo{name: "ui/index.html", size: 8855, mode: os.FileMode(436), modTime: time.Unix(15306
25365
, 0)}
info := bindataFileInfo{name: "ui/index.html", size: 8855, mode: os.FileMode(436), modTime: time.Unix(15306
93618
, 0)}
a := &asset{bytes: bytes, info: info}
a := &asset{bytes: bytes, info: info}
return a, nil
return a, nil
}
}
...
@@ -113,7 +113,7 @@ func uiCssBootstrapRebootMinCss() (*asset, error) {
...
@@ -113,7 +113,7 @@ func uiCssBootstrapRebootMinCss() (*asset, error) {
return nil, err
return nil, err
}
}
info := bindataFileInfo{name: "ui/css/bootstrap-reboot.min.css", size: 3989, mode: os.FileMode(4
20
), modTime: time.Unix(15
25033372
, 0)}
info := bindataFileInfo{name: "ui/css/bootstrap-reboot.min.css", size: 3989, mode: os.FileMode(4
36
), modTime: time.Unix(15
30321195
, 0)}
a := &asset{bytes: bytes, info: info}
a := &asset{bytes: bytes, info: info}
return a, nil
return a, nil
}
}
...
@@ -133,7 +133,7 @@ func uiCssBootstrapRebootMinCssMap() (*asset, error) {
...
@@ -133,7 +133,7 @@ func uiCssBootstrapRebootMinCssMap() (*asset, error) {
return nil, err
return nil, err
}
}
info := bindataFileInfo{name: "ui/css/bootstrap-reboot.min.css.map", size: 25857, mode: os.FileMode(4
36
), modTime: time.Unix(15
30624697
, 0)}
info := bindataFileInfo{name: "ui/css/bootstrap-reboot.min.css.map", size: 25857, mode: os.FileMode(4
20
), modTime: time.Unix(15
25065771
, 0)}
a := &asset{bytes: bytes, info: info}
a := &asset{bytes: bytes, info: info}
return a, nil
return a, nil
}
}
...
@@ -153,7 +153,7 @@ func uiCssBootstrapMinCss() (*asset, error) {
...
@@ -153,7 +153,7 @@ func uiCssBootstrapMinCss() (*asset, error) {
return nil, err
return nil, err
}
}
info := bindataFileInfo{name: "ui/css/bootstrap.min.css", size: 140930, mode: os.FileMode(4
20
), modTime: time.Unix(15
25033370
, 0)}
info := bindataFileInfo{name: "ui/css/bootstrap.min.css", size: 140930, mode: os.FileMode(4
36
), modTime: time.Unix(15
30321195
, 0)}
a := &asset{bytes: bytes, info: info}
a := &asset{bytes: bytes, info: info}
return a, nil
return a, nil
}
}
...
@@ -173,7 +173,7 @@ func uiCssBootstrapMinCssMap() (*asset, error) {
...
@@ -173,7 +173,7 @@ func uiCssBootstrapMinCssMap() (*asset, error) {
return nil, err
return nil, err
}
}
info := bindataFileInfo{name: "ui/css/bootstrap.min.css.map", size: 559636, mode: os.FileMode(4
36
), modTime: time.Unix(15
30624
69
7
, 0)}
info := bindataFileInfo{name: "ui/css/bootstrap.min.css.map", size: 559636, mode: os.FileMode(4
20
), modTime: time.Unix(15
250657
69, 0)}
a := &asset{bytes: bytes, info: info}
a := &asset{bytes: bytes, info: info}
return a, nil
return a, nil
}
}
...
@@ -193,7 +193,7 @@ func uiCssMainCss() (*asset, error) {
...
@@ -193,7 +193,7 @@ func uiCssMainCss() (*asset, error) {
return nil, err
return nil, err
}
}
info := bindataFileInfo{name: "ui/css/main.css", size: 232, mode: os.FileMode(436), modTime: time.Unix(15303
14832
, 0)}
info := bindataFileInfo{name: "ui/css/main.css", size: 232, mode: os.FileMode(436), modTime: time.Unix(15303
21195
, 0)}
a := &asset{bytes: bytes, info: info}
a := &asset{bytes: bytes, info: info}
return a, nil
return a, nil
}
}
...
@@ -213,7 +213,7 @@ func uiJsBootstrapBundleMinJs() (*asset, error) {
...
@@ -213,7 +213,7 @@ func uiJsBootstrapBundleMinJs() (*asset, error) {
return nil, err
return nil, err
}
}
info := bindataFileInfo{name: "ui/js/bootstrap.bundle.min.js", size: 70682, mode: os.FileMode(4
20
), modTime: time.Unix(15303
05287
, 0)}
info := bindataFileInfo{name: "ui/js/bootstrap.bundle.min.js", size: 70682, mode: os.FileMode(4
36
), modTime: time.Unix(15303
21195
, 0)}
a := &asset{bytes: bytes, info: info}
a := &asset{bytes: bytes, info: info}
return a, nil
return a, nil
}
}
...
@@ -233,7 +233,7 @@ func uiJsBootstrapBundleMinJsMap() (*asset, error) {
...
@@ -233,7 +233,7 @@ func uiJsBootstrapBundleMinJsMap() (*asset, error) {
return nil, err
return nil, err
}
}
info := bindataFileInfo{name: "ui/js/bootstrap.bundle.min.js.map", size: 292629, mode: os.FileMode(4
36
), modTime: time.Unix(15
3062469
7, 0)}
info := bindataFileInfo{name: "ui/js/bootstrap.bundle.min.js.map", size: 292629, mode: os.FileMode(4
20
), modTime: time.Unix(15
2506577
7, 0)}
a := &asset{bytes: bytes, info: info}
a := &asset{bytes: bytes, info: info}
return a, nil
return a, nil
}
}
...
@@ -253,7 +253,7 @@ func uiJsJqueryMinJs() (*asset, error) {
...
@@ -253,7 +253,7 @@ func uiJsJqueryMinJs() (*asset, error) {
return nil, err
return nil, err
}
}
info := bindataFileInfo{name: "ui/js/jquery.min.js", size: 86927, mode: os.FileMode(436), modTime: time.Unix(15
16469204
, 0)}
info := bindataFileInfo{name: "ui/js/jquery.min.js", size: 86927, mode: os.FileMode(436), modTime: time.Unix(15
30321195
, 0)}
a := &asset{bytes: bytes, info: info}
a := &asset{bytes: bytes, info: info}
return a, nil
return a, nil
}
}
...
@@ -273,7 +273,7 @@ func uiJsMainJs() (*asset, error) {
...
@@ -273,7 +273,7 @@ func uiJsMainJs() (*asset, error) {
return nil, err
return nil, err
}
}
info := bindataFileInfo{name: "ui/js/main.js", size: 13376, mode: os.FileMode(436), modTime: time.Unix(15306
2776
8, 0)}
info := bindataFileInfo{name: "ui/js/main.js", size: 13376, mode: os.FileMode(436), modTime: time.Unix(15306
9361
8, 0)}
a := &asset{bytes: bytes, info: info}
a := &asset{bytes: bytes, info: info}
return a, nil
return a, nil
}
}
...
...
This diff is collapsed.
Click to expand it.
store/files.go
+
14
−
0
View file @
3fff558c
...
@@ -74,6 +74,20 @@ func (st *Store) UpdateFile(group string, id uint64, file File) (*File, error) {
...
@@ -74,6 +74,20 @@ func (st *Store) UpdateFile(group string, id uint64, file File) (*File, error) {
return
&
file
,
err
return
&
file
,
err
}
}
func
(
st
*
Store
)
UpdateFileMetadata
(
group
string
,
id
uint64
,
metadata
map
[
string
]
interface
{})
(
*
File
,
error
)
{
file
:=
&
File
{
ID
:
id
}
md
:=
make
(
map
[
string
]
interface
{})
for
key
,
value
:=
range
metadata
{
md
[
"metadata__"
+
key
]
=
value
}
// make sure the file actually belongs to <group> since permissions are enforced
// based on group membership
if
err
:=
st
.
db
.
Model
(
&
file
)
.
Where
(
"group_name = ?"
,
group
)
.
Update
(
md
)
.
Error
;
err
!=
nil
{
return
nil
,
err
}
return
file
,
nil
}
func
(
st
*
Store
)
getFileUsage
(
id
uint64
,
playlists
*
Playlists
)
(
err
error
)
{
func
(
st
*
Store
)
getFileUsage
(
id
uint64
,
playlists
*
Playlists
)
(
err
error
)
{
sub
:=
st
.
db
.
Model
(
PlaylistEntry
{})
.
Select
(
"playlist_id"
)
.
Where
(
"file_id = ?"
,
id
)
.
Group
(
"playlist_id"
)
.
SubQuery
()
sub
:=
st
.
db
.
Model
(
PlaylistEntry
{})
.
Select
(
"playlist_id"
)
.
Where
(
"file_id = ?"
,
id
)
.
Group
(
"playlist_id"
)
.
SubQuery
()
err
=
st
.
db
.
Where
(
"id in ?"
,
sub
)
.
Find
(
playlists
)
.
Error
err
=
st
.
db
.
Where
(
"id in ?"
,
sub
)
.
Find
(
playlists
)
.
Error
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment