mirror of
https://github.com/zoriya/Kyoo.git
synced 2025-05-31 04:04:21 -04:00
Fix versions update for info
This commit is contained in:
parent
6208fd2b8d
commit
6a431a5bb4
@ -67,6 +67,8 @@ create table chapters(
|
|||||||
end_time real not null,
|
end_time real not null,
|
||||||
name varchar(1024),
|
name varchar(1024),
|
||||||
type chapter_type
|
type chapter_type
|
||||||
|
|
||||||
|
constraint chapter_pk primary key (sha, start_time)
|
||||||
);
|
);
|
||||||
|
|
||||||
commit;
|
commit;
|
||||||
|
@ -210,24 +210,64 @@ func (s *MetadataService) storeFreshMetadata(path string, sha string) (*MediaInf
|
|||||||
}
|
}
|
||||||
|
|
||||||
tx, err := s.database.Begin()
|
tx, err := s.database.Begin()
|
||||||
_, err = tx.Exec(
|
_, err = tx.Exec(`
|
||||||
`insert into info(sha, path, extension, mime_codec, size, duration, container,
|
do language plpgsql
|
||||||
fonts, ver_info, ver_extract, ver_thumbs, ver_keyframes)
|
$$
|
||||||
values ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12)`,
|
begin
|
||||||
|
insert into info(sha, path, extension, mime_codec, size, duration, container,
|
||||||
|
fonts, ver_info, ver_extract, ver_thumbs, ver_keyframes)
|
||||||
|
values ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12);
|
||||||
|
return;
|
||||||
|
exception when unique_violation then
|
||||||
|
update info set
|
||||||
|
sha = $1,
|
||||||
|
path = $2,
|
||||||
|
extension = $3,
|
||||||
|
mime_codec = $4,
|
||||||
|
size = $5,
|
||||||
|
duration = $6,
|
||||||
|
container = $7,
|
||||||
|
fonts = $8,
|
||||||
|
ver_info = $9
|
||||||
|
where sha = $1 or path = $2;
|
||||||
|
end;
|
||||||
|
$$;
|
||||||
|
`,
|
||||||
|
// on conflict do not update versions of extract/thumbs/keyframes
|
||||||
ret.Sha, ret.Path, ret.Extension, ret.MimeCodec, ret.Size, ret.Duration, ret.Container,
|
ret.Sha, ret.Path, ret.Extension, ret.MimeCodec, ret.Size, ret.Duration, ret.Container,
|
||||||
pq.Array(ret.Fonts), ret.Versions.Info, ret.Versions.Extract, ret.Versions.Thumbs, ret.Versions.Keyframes,
|
pq.Array(ret.Fonts), ret.Versions.Info, ret.Versions.Extract, ret.Versions.Thumbs, ret.Versions.Keyframes,
|
||||||
)
|
)
|
||||||
for _, v := range ret.Videos {
|
for _, v := range ret.Videos {
|
||||||
tx.Exec(
|
tx.Exec(
|
||||||
`insert into videos(sha, idx, title, language, codec, mime_codec, width, height, bitrate)
|
`insert into videos(sha, idx, title, language, codec, mime_codec, width, height, bitrate)
|
||||||
values ($1, $2, $3, $4, $5, $6, $7, $8, $9)`,
|
values ($1, $2, $3, $4, $5, $6, $7, $8, $9)
|
||||||
|
on conflict (sha, idx) do update set
|
||||||
|
sha = excluded.sha,
|
||||||
|
idx = excluded.idx,
|
||||||
|
title = excluded.title,
|
||||||
|
language = excluded.language,
|
||||||
|
codec = excluded.codec,
|
||||||
|
mime_codec = excluded.mime_codec,
|
||||||
|
width = excluded.width,
|
||||||
|
height = excluded.height,
|
||||||
|
bitrate = excluded.bitrate
|
||||||
|
`,
|
||||||
ret.Sha, v.Index, v.Title, v.Language, v.Codec, v.MimeCodec, v.Width, v.Height, v.Bitrate,
|
ret.Sha, v.Index, v.Title, v.Language, v.Codec, v.MimeCodec, v.Width, v.Height, v.Bitrate,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
for _, a := range ret.Audios {
|
for _, a := range ret.Audios {
|
||||||
tx.Exec(
|
tx.Exec(
|
||||||
`insert into audios(sha, idx, title, language, codec, mime_codec, is_default)
|
`insert into audios(sha, idx, title, language, codec, mime_codec, is_default)
|
||||||
values ($1, $2, $3, $4, $5, $6, $7)`,
|
values ($1, $2, $3, $4, $5, $6, $7)
|
||||||
|
on conflict (sha, idx) do update set
|
||||||
|
sha = excluded.sha,
|
||||||
|
idx = excluded.idx,
|
||||||
|
title = excluded.title,
|
||||||
|
language = excluded.language,
|
||||||
|
codec = excluded.codec,
|
||||||
|
mime_codec = excluded.mime_codec,
|
||||||
|
is_default = excluded.is_default
|
||||||
|
`,
|
||||||
ret.Sha, a.Index, a.Title, a.Language, a.Codec, a.MimeCodec, a.IsDefault,
|
ret.Sha, a.Index, a.Title, a.Language, a.Codec, a.MimeCodec, a.IsDefault,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@ -241,7 +281,14 @@ func (s *MetadataService) storeFreshMetadata(path string, sha string) (*MediaInf
|
|||||||
for _, c := range ret.Chapters {
|
for _, c := range ret.Chapters {
|
||||||
tx.Exec(
|
tx.Exec(
|
||||||
`insert into chapters(sha, start_time, end_time, name, type)
|
`insert into chapters(sha, start_time, end_time, name, type)
|
||||||
values ($1, $2, $3, $4, $5)`,
|
values ($1, $2, $3, $4, $5)
|
||||||
|
on conflict (sha, start_time) do update set
|
||||||
|
sha = excluded.sha,
|
||||||
|
start_time = excluded.start_time,
|
||||||
|
end_time = excluded.end_time,
|
||||||
|
name = excluded.name,
|
||||||
|
type = excluded.type
|
||||||
|
`,
|
||||||
ret.Sha, c.StartTime, c.EndTime, c.Name, c.Type,
|
ret.Sha, c.StartTime, c.EndTime, c.Name, c.Type,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user