self.db.executemany("""
INSERT INTO
- filelists
+ package_files
(
pkg_id,
path,
LEFT JOIN jobs_packages pkgs ON jobs.id = pkgs.job_id \
WHERE pkgs.pkg_id = %s", self.id)
- @lazy_property
- def filelist(self):
- res = self.db.query("SELECT * FROM filelists \
- WHERE pkg_id = %s ORDER BY path", self.id)
+ # Files
- ret = []
- for row in res:
- f = File(self.backend, self, row)
- ret.append(f)
+ def _get_files(self, query, *args):
+ res = self.db.query(query, *args)
- return ret
+ for row in res:
+ yield File(self.backend, row.id, data=row)
- def get_file(self, filename):
- res = self.db.get("SELECT * FROM filelists \
- WHERE pkg_id = %s AND path = %s", self.id, filename)
+ def _get_file(self, query, *args):
+ res = self.db.get(query, *args)
if res:
- return File(self.backend, self, res)
+ return File(self.backend, res.id, data=res)
+
+ @lazy_property
+ def files(self):
+ files = self._get_files("""
+ SELECT
+ *
+ FROM
+ package_files
+ WHERE
+ pkg_id = %s
+ ORDER BY
+ path
+ """, self.id,
+ )
+
+ return list(files)
+
+ def get_file(self, path):
+ return self._get_file("""
+ SELECT
+ *
+ FROM
+ package_files
+ WHERE
+ pkg_id = %s
+ AND
+ path = %s
+ """, self.id, path,
+ )
+
+ # Open
async def open(self):
"""
ALTER SEQUENCE public.distributions_id_seq OWNED BY public.distributions.id;
---
--- Name: filelists; Type: TABLE; Schema: public; Owner: -
---
-
-CREATE TABLE public.filelists (
- pkg_id integer NOT NULL,
- path text NOT NULL,
- size bigint NOT NULL,
- config boolean DEFAULT false NOT NULL,
- mode integer NOT NULL,
- uname text NOT NULL,
- gname text NOT NULL,
- capabilities text,
- ctime timestamp without time zone NOT NULL,
- mtime timestamp without time zone NOT NULL,
- digest_sha2_512 bytea,
- digest_sha2_256 bytea,
- digest_blake2b512 bytea,
- digest_blake2s256 bytea,
- digest_sha3_512 bytea,
- digest_sha3_256 bytea
-);
-
-
--
-- Name: images_types; Type: TABLE; Schema: public; Owner: -
--
COMMENT ON VIEW public.package_estimated_build_times IS 'Should add this later: AND jobs.time_finished >= (CURRENT_TIMESTAMP - ''180 days''::interval)';
+--
+-- Name: package_files; Type: TABLE; Schema: public; Owner: -
+--
+
+CREATE TABLE public.package_files (
+ pkg_id integer NOT NULL,
+ path text NOT NULL,
+ size bigint NOT NULL,
+ config boolean DEFAULT false NOT NULL,
+ mode integer NOT NULL,
+ uname text NOT NULL,
+ gname text NOT NULL,
+ capabilities text,
+ ctime timestamp without time zone NOT NULL,
+ mtime timestamp without time zone NOT NULL,
+ digest_sha2_512 bytea,
+ digest_sha2_256 bytea,
+ digest_blake2b512 bytea,
+ digest_blake2s256 bytea,
+ digest_sha3_512 bytea,
+ digest_sha3_256 bytea
+);
+
+
--
-- Name: package_search_index_generator; Type: VIEW; Schema: public; Owner: -
--
CREATE UNIQUE INDEX distributions_slug ON public.distributions USING btree (slug) WHERE (deleted IS FALSE);
---
--- Name: filelists_path; Type: INDEX; Schema: public; Owner: -
---
-
-CREATE INDEX filelists_path ON public.filelists USING btree (path);
-
-
---
--- Name: filelists_pkg_id; Type: INDEX; Schema: public; Owner: -
---
-
-CREATE INDEX filelists_pkg_id ON public.filelists USING btree (pkg_id);
-
-ALTER TABLE public.filelists CLUSTER ON filelists_pkg_id;
-
-
--
-- Name: idx_2198147_name; Type: INDEX; Schema: public; Owner: -
--
ALTER TABLE public.mirrors_checks CLUSTER ON mirrors_checks_sort;
+--
+-- Name: package_files_path; Type: INDEX; Schema: public; Owner: -
+--
+
+CREATE INDEX package_files_path ON public.package_files USING btree (path);
+
+
+--
+-- Name: package_files_pkg_id; Type: INDEX; Schema: public; Owner: -
+--
+
+CREATE INDEX package_files_pkg_id ON public.package_files USING btree (pkg_id);
+
+
--
-- Name: package_search_index_unique; Type: INDEX; Schema: public; Owner: -
--
ADD CONSTRAINT builds_pkg_id FOREIGN KEY (pkg_id) REFERENCES public.packages(id);
---
--- Name: filelists filelists_pkg_id; Type: FK CONSTRAINT; Schema: public; Owner: -
---
-
-ALTER TABLE ONLY public.filelists
- ADD CONSTRAINT filelists_pkg_id FOREIGN KEY (pkg_id) REFERENCES public.packages(id);
-
-
--
-- Name: jobs jobs_build_id; Type: FK CONSTRAINT; Schema: public; Owner: -
--
ADD CONSTRAINT mirrors_checks_mirror_id FOREIGN KEY (mirror_id) REFERENCES public.mirrors(id);
+--
+-- Name: package_files package_files_pkg_id; Type: FK CONSTRAINT; Schema: public; Owner: -
+--
+
+ALTER TABLE ONLY public.package_files
+ ADD CONSTRAINT package_files_pkg_id FOREIGN KEY (pkg_id) REFERENCES public.packages(id);
+
+
--
-- Name: packages packages_commit_id; Type: FK CONSTRAINT; Schema: public; Owner: -
--