forked from importers/git-importer
		
	Compare commits
	
		
			1 Commits
		
	
	
		
			typo
			...
			add_old_st
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
|  | 716db10adf | 
| @@ -7,6 +7,8 @@ import sys | ||||
|  | ||||
| import osc.core | ||||
|  | ||||
| from lib.db import DB | ||||
| from lib.db_revision import DBRevision | ||||
| from lib.git_exporter import GitExporter | ||||
| from lib.importer import Importer | ||||
| from lib.test_exporter import TestExporter | ||||
| @@ -100,6 +102,56 @@ def main(): | ||||
|             requests_log.setLevel(logging.DEBUG) | ||||
|             requests_log.propagate = True | ||||
|  | ||||
|     def check_old_package(db: DB, dir: pathlib.Path): | ||||
|         md5file = dir / "MD5SUMS" | ||||
|         print(md5file) | ||||
|         valid_revisions = None | ||||
|         with open(md5file, "rb") as f: | ||||
|             for line in f.readlines(): | ||||
|                 try: | ||||
|                     md5, file = line.decode("utf-8").strip().split("  ") | ||||
|                 except UnicodeDecodeError: | ||||
|                     logging.error(f"Corrupt MD5 file: {md5file}") | ||||
|                     return | ||||
|                 if file == "ready": | ||||
|                     continue | ||||
|                 if len(md5) != 32: | ||||
|                     logging.error(f"Corrupt MD5 file: {md5file}") | ||||
|                     return | ||||
|                 with db.cursor() as cur: | ||||
|                     cur.execute( | ||||
|                         "SELECT revision_id FROM files WHERE md5=%s AND name=%s", | ||||
|                         (md5, file), | ||||
|                     ) | ||||
|                     nrevs = set([row[0] for row in cur.fetchall()]) | ||||
|                     if valid_revisions is None: | ||||
|                         valid_revisions = nrevs | ||||
|                     else: | ||||
|                         valid_revisions = valid_revisions & nrevs | ||||
|                     if not valid_revisions: | ||||
|                         break | ||||
|  | ||||
|         with db.cursor() as cur: | ||||
|             cur.execute( | ||||
|                 "SELECT * FROM revisions WHERE id = ANY(%s) AND project=%s", | ||||
|                 (list(valid_revisions), "openSUSE:Factory"), | ||||
|             ) | ||||
|             for row in cur.fetchall(): | ||||
|                 r = DBRevision(db, row) | ||||
|                 print("Valid", r, r.files_hash) | ||||
|                 return True | ||||
|  | ||||
|     if False: | ||||
|         import os | ||||
|  | ||||
|         db = DB() | ||||
|         basedir = pathlib.Path( | ||||
|             f"/mounts/work/SAVE/oldpackages/stable/{args.packages[0]}" | ||||
|         ) | ||||
|         for subdir in sorted(os.listdir(basedir)): | ||||
|             if check_old_package(db, basedir / subdir): | ||||
|                 break | ||||
|  | ||||
|     if args.export: | ||||
|         if len(args.packages) != 1: | ||||
|             print("Can only export one package") | ||||
|   | ||||
		Reference in New Issue
	
	Block a user