aboutsummaryrefslogtreecommitdiff
path: root/src/hydrilla/proxy/state_impl/prune_packages.py
diff options
context:
space:
mode:
authorWojtek Kosior <koszko@koszko.org>2022-08-22 12:52:59 +0200
committerWojtek Kosior <koszko@koszko.org>2022-09-28 12:54:51 +0200
commit8238435825d01ad2ec1a11b6bcaf6d9a9aad5ab5 (patch)
tree4c4956e45701460bedaa0d8b0be808052152777f /src/hydrilla/proxy/state_impl/prune_packages.py
parente1344ae7017b28a54d7714895bd54c8431a20bc6 (diff)
downloadhaketilo-hydrilla-8238435825d01ad2ec1a11b6bcaf6d9a9aad5ab5.tar.gz
haketilo-hydrilla-8238435825d01ad2ec1a11b6bcaf6d9a9aad5ab5.zip
allow pulling packages from remote repository
Diffstat (limited to 'src/hydrilla/proxy/state_impl/prune_packages.py')
-rw-r--r--src/hydrilla/proxy/state_impl/prune_packages.py152
1 files changed, 0 insertions, 152 deletions
diff --git a/src/hydrilla/proxy/state_impl/prune_packages.py b/src/hydrilla/proxy/state_impl/prune_packages.py
deleted file mode 100644
index 1857188..0000000
--- a/src/hydrilla/proxy/state_impl/prune_packages.py
+++ /dev/null
@@ -1,152 +0,0 @@
-# SPDX-License-Identifier: GPL-3.0-or-later
-
-# Haketilo proxy data and configuration (removal of packages that are not used).
-#
-# This file is part of Hydrilla&Haketilo.
-#
-# Copyright (C) 2022 Wojtek Kosior
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program. If not, see <https://www.gnu.org/licenses/>.
-#
-#
-# I, Wojtek Kosior, thereby promise not to sue for violation of this
-# file's license. Although I request that you do not make use this code
-# in a proprietary program, I am not going to enforce this in court.
-
-"""
-....
-"""
-
-# Enable using with Python 3.7.
-from __future__ import annotations
-
-import sqlite3
-
-
-_remove_mapping_versions_sql = '''
-WITH removed_mappings AS (
- SELECT
- iv.item_version_id
- FROM
- item_versions AS iv
- JOIN items AS i
- USING (item_id)
- JOIN orphan_iterations AS oi
- USING (repo_iteration_id)
- LEFT JOIN payloads AS p
- ON p.mapping_item_id = iv.item_version_id
- WHERE
- i.type = 'M' AND p.payload_id IS NULL
-)
-DELETE FROM
- item_versions
-WHERE
- item_version_id IN removed_mappings;
-'''
-
-_remove_resource_versions_sql = '''
-WITH removed_resources AS (
- SELECT
- iv.item_version_id
- FROM
- item_versions AS iv
- JOIN items AS i
- USING (item_id)
- JOIN orphan_iterations AS oi
- USING (repo_iteration_id)
- LEFT JOIN resolved_depended_resources AS rdr
- ON rdr.resource_item_id = iv.item_version_id
- WHERE
- rdr.payload_id IS NULL
-)
-DELETE FROM
- item_versions
-WHERE
- item_version_id IN removed_resources;
-'''
-
-_remove_items_sql = '''
-WITH removed_items AS (
- SELECT
- i.item_id
- FROM
- items AS i
- LEFT JOIN item_versions AS iv USING (item_id)
- LEFT JOIN mapping_statuses AS ms USING (item_id)
- WHERE
- iv.item_version_id IS NULL AND
- i.type = 'R' OR ms.enabled = 'N'
-)
-DELETE FROM
- items
-WHERE
- item_id IN removed_items;
-'''
-
-_remove_files_sql = '''
-WITH removed_files AS (
- SELECT
- f.file_id
- FROM
- files AS f
- LEFT JOIN file_uses AS fu USING (file_id)
- WHERE
- fu.file_use_id IS NULL
-)
-DELETE FROM
- files
-WHERE
- file_id IN removed_files;
-'''
-
-_remove_repo_iterations_sql = '''
-WITH removed_iterations AS (
- SELECT
- oi.repo_iteration_id
- FROM
- orphan_iterations AS oi
- LEFT JOIN item_versions AS iv USING (repo_iteration_id)
- WHERE
- iv.item_version_id IS NULL
-)
-DELETE FROM
- repo_iterations
-WHERE
- repo_iteration_id IN removed_iterations;
-'''
-
-_remove_repos_sql = '''
-WITH removed_repos AS (
- SELECT
- r.repo_id
- FROM
- repos AS r
- LEFT JOIN repo_iterations AS ri USING (repo_id)
- WHERE
- r.deleted AND ri.repo_iteration_id IS NULL
-)
-DELETE FROM
- repos
-WHERE
- repo_id IN removed_repos;
-'''
-
-def prune(cursor: sqlite3.Cursor) -> None:
- """...."""
- cursor.execute(_remove_mapping_versions_sql)
- cursor.execute(_remove_resource_versions_sql)
- cursor.execute(_remove_items_sql)
- cursor.execute(_remove_files_sql)
- cursor.execute(_remove_repo_iterations_sql)
- cursor.execute(_remove_repos_sql)