From 482785c5e6a1acdba8750b99b13288ad62c6d29d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Guillot?= Date: Wed, 14 Mar 2018 20:09:06 -0700 Subject: [PATCH] Convert enclosure size field to bigint --- model/enclosure.go | 2 +- reader/atom/atom.go | 2 +- reader/json/json.go | 2 +- reader/rss/rss.go | 2 +- sql/schema_version_15.sql | 1 + sql/sql.go | 4 +++- storage/migration.go | 2 +- 7 files changed, 9 insertions(+), 6 deletions(-) create mode 100644 sql/schema_version_15.sql diff --git a/model/enclosure.go b/model/enclosure.go index 5a52f781..6de1af73 100644 --- a/model/enclosure.go +++ b/model/enclosure.go @@ -11,7 +11,7 @@ type Enclosure struct { EntryID int64 `json:"entry_id"` URL string `json:"url"` MimeType string `json:"mime_type"` - Size int `json:"size"` + Size int64 `json:"size"` } // EnclosureList represents a list of attachments. diff --git a/reader/atom/atom.go b/reader/atom/atom.go index 46971259..96a429fb 100644 --- a/reader/atom/atom.go +++ b/reader/atom/atom.go @@ -187,7 +187,7 @@ func getEnclosures(a *atomEntry) model.EnclosureList { for _, link := range a.Links { if strings.ToLower(link.Rel) == "enclosure" { - length, _ := strconv.Atoi(link.Length) + length, _ := strconv.ParseInt(link.Length, 10, 0) enclosures = append(enclosures, &model.Enclosure{URL: link.URL, MimeType: link.Type, Size: length}) } } diff --git a/reader/json/json.go b/reader/json/json.go index 81b38f6b..2c812abf 100644 --- a/reader/json/json.go +++ b/reader/json/json.go @@ -47,7 +47,7 @@ type jsonAttachment struct { URL string `json:"url"` MimeType string `json:"mime_type"` Title string `json:"title"` - Size int `json:"size_in_bytes"` + Size int64 `json:"size_in_bytes"` Duration int `json:"duration_in_seconds"` } diff --git a/reader/rss/rss.go b/reader/rss/rss.go index b7fc1d0f..041cd198 100644 --- a/reader/rss/rss.go +++ b/reader/rss/rss.go @@ -194,7 +194,7 @@ func (r *rssItem) GetEnclosures() model.EnclosureList { enclosures := make(model.EnclosureList, 0) for _, enclosure := range r.Enclosures { - length, _ := strconv.Atoi(enclosure.Length) + length, _ := strconv.ParseInt(enclosure.Length, 10, 0) enclosureURL := enclosure.URL if r.OrigEnclosureLink != "" { diff --git a/sql/schema_version_15.sql b/sql/schema_version_15.sql new file mode 100644 index 00000000..b5cb3862 --- /dev/null +++ b/sql/schema_version_15.sql @@ -0,0 +1 @@ +alter table enclosures alter column size set data type bigint; \ No newline at end of file diff --git a/sql/sql.go b/sql/sql.go index 80be63ff..f6aa19ed 100644 --- a/sql/sql.go +++ b/sql/sql.go @@ -1,5 +1,5 @@ // Code generated by go generate; DO NOT EDIT. -// 2018-02-24 17:47:34.98646993 +0000 GMT +// 2018-03-14 19:16:10.293618552 -0700 PDT m=+0.003182755 package sql @@ -129,6 +129,7 @@ create index feeds_user_category_idx on feeds(user_id, category_id); "schema_version_14": `alter table integrations add column nunux_keeper_enabled bool default 'f'; alter table integrations add column nunux_keeper_url text default ''; alter table integrations add column nunux_keeper_api_key text default '';`, + "schema_version_15": `alter table enclosures alter column size set data type bigint;`, "schema_version_2": `create extension if not exists hstore; alter table users add column extra hstore; create index users_extra_idx on users using gin(extra); @@ -174,6 +175,7 @@ var SqlMapChecksums = map[string]string{ "schema_version_12": "a95abab6cdf64811fc744abd37457e2928939d999c5ef00d2bdd9398e16f32fb", "schema_version_13": "9073fae1e796936f4a43a8120ebdb4218442fe7d346ace6387556a357c2d7edf", "schema_version_14": "4622e42c4a5a88b6fe1e61f3d367b295968f7260ab5b96481760775ba9f9e1fe", + "schema_version_15": "13ff91462bdf4cda5a94a4c7a09f757761b0f2c32b4be713ba4786a4837750e4", "schema_version_2": "e8e9ff32478df04fcddad10a34cba2e8bb1e67e7977b5bd6cdc4c31ec94282b4", "schema_version_3": "a54745dbc1c51c000f74d4e5068f1e2f43e83309f023415b1749a47d5c1e0f12", "schema_version_4": "216ea3a7d3e1704e40c797b5dc47456517c27dbb6ca98bf88812f4f63d74b5d9", diff --git a/storage/migration.go b/storage/migration.go index ed219ded..9d6316af 100644 --- a/storage/migration.go +++ b/storage/migration.go @@ -12,7 +12,7 @@ import ( "github.com/miniflux/miniflux/sql" ) -const schemaVersion = 14 +const schemaVersion = 15 // Migrate run database migrations. func (s *Storage) Migrate() {