Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 43e95e17 authored by Nicola Corna's avatar Nicola Corna
Browse files

Fix old file removal

parent 7e1ccbb8
Loading
Loading
Loading
Loading
+11 −3
Original line number Diff line number Diff line
@@ -299,7 +299,7 @@ for branch in $BRANCH_NAME; do
                echo ">> [$(date)] Delta generation for $codename failed" | tee -a "$DEBUG_LOG"
              fi
              if [ "$DELETE_OLD_DELTAS" -gt "0" ]; then
                /usr/bin/python /root/clean_up.py -n $DELETE_OLD_DELTAS -V $los_ver -N 1 "$DELTA_DIR" &>> $DEBUG_LOG
                /usr/bin/python /root/clean_up.py -n $DELETE_OLD_DELTAS -V $los_ver -N 1 "$DELTA_DIR/$codename" &>> $DEBUG_LOG
              fi
              cd "$source_dir"
            else
@@ -324,10 +324,18 @@ for branch in $BRANCH_NAME; do

        # Remove old zips and logs
        if [ "$DELETE_OLD_ZIPS" -gt "0" ]; then
          /usr/bin/python /root/clean_up.py -n $DELETE_OLD_ZIPS -V $los_ver -N 1 "$ZIP_DIR"
          if [ "$ZIP_SUBDIR" = true ]; then
            /usr/bin/python /root/clean_up.py -n $DELETE_OLD_ZIPS -V $los_ver -N 1 "$ZIP_DIR/$zipsubdir"
          else
            /usr/bin/python /root/clean_up.py -n $DELETE_OLD_ZIPS -V $los_ver -N 1 -c $codename "$ZIP_DIR"
          fi
        fi
        if [ "$DELETE_OLD_LOGS" -gt "0" ]; then
          /usr/bin/python /root/clean_up.py -n $DELETE_OLD_LOGS -V $los_ver -N 1 "$LOGS_DIR"
          if [ "$LOGS_SUBDIR" = true ]; then
            /usr/bin/python /root/clean_up.py -n $DELETE_OLD_LOGS -V $los_ver -N 1 "$LOGS_DIR/$logsubdir"
          else
            /usr/bin/python /root/clean_up.py -n $DELETE_OLD_LOGS -V $los_ver -N 1 -c $codename "$LOGS_DIR"
          fi
        fi
        if [ -f /root/userscripts/post-build.sh ]; then
          echo ">> [$(date)] Running post-build.sh for $codename" >> "$DEBUG_LOG"
+15 −11
Original line number Diff line number Diff line
@@ -26,7 +26,8 @@ from argparse import ArgumentParser

ROM_NAME = "lineage"

def clean_path(path, builds_to_keep, current_version, old_builds_to_keep):
def clean_path(path, builds_to_keep, current_version, old_builds_to_keep,
               current_codename):
    files = []
    scandir = path[:-1] if path[-1] == "/" else path

@@ -61,6 +62,7 @@ def clean_path(path, builds_to_keep, current_version, old_builds_to_keep):
        build_list.sort(key=lambda b: b[0])
        n_builds = len(build_list)

        if not current_codename or build_hash[1] == current_codename:
            if current_version:
                if current_version == build_hash[0]:
                    keep_num = builds_to_keep
@@ -87,9 +89,11 @@ def main():
    parser.add_argument('-N', metavar='N_BUILDS_OLD', type=int, nargs='?',
                        default=1, help='select the number of builds to keep '
                        'when not of the specified version')
    parser.add_argument('-c', metavar='CODENAME', type=str, nargs='?',
                        help='clean only CODENAME zips')
    args = parser.parse_args()
    for path in args.paths:
        clean_path(path, args.n, args.V, args.N)
        clean_path(path, args.n, args.V, args.N, args.c)


if __name__ == "__main__":