From bb9e85d77770d0c3daa2701b43d0ed0ec2156ec9 Mon Sep 17 00:00:00 2001 From: varyg <88599103+varyg1001@users.noreply.github.com> Date: Sun, 12 Feb 2023 20:25:39 +0100 Subject: [PATCH 1/2] Use shutil.move to move data instead of Path.rename Path.rename() cannot move data to different drives. It can only rename the path reference on the same file system. However, shutil.move() will move the data while also changing it's name. --- devine/commands/auth.py | 3 ++- devine/commands/dl.py | 3 ++- devine/core/tracks/track.py | 6 ++++-- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/devine/commands/auth.py b/devine/commands/auth.py index cf7ab21..aa49b40 100644 --- a/devine/commands/auth.py +++ b/devine/commands/auth.py @@ -1,5 +1,6 @@ import logging import sys +import shutil import tkinter.filedialog from collections import defaultdict from pathlib import Path @@ -243,7 +244,7 @@ def add(ctx: click.Context, profile: str, service: str, cookie: Optional[str] = if final_path.exists(): log.error(f"A Cookie file for the Profile {profile} on {service} already exists.") sys.exit(1) - cookie = cookie.rename(final_path) + shutil.move(cookie, final_path) log.info(f"Moved Cookie file to: {cookie}") if credential: diff --git a/devine/commands/dl.py b/devine/commands/dl.py index 1b6c01e..1994566 100644 --- a/devine/commands/dl.py +++ b/devine/commands/dl.py @@ -5,6 +5,7 @@ import logging import math import random import re +import shutil import sys import time import traceback @@ -674,7 +675,7 @@ class dl: final_dir.mkdir(parents=True, exist_ok=True) final_path = final_dir / f"{final_filename}{muxed_path.suffix}" - muxed_path.rename(final_path) + shutil.move(muxed_path, final_path) self.log.info(f" + Moved to {final_path}") @staticmethod diff --git a/devine/core/tracks/track.py b/devine/core/tracks/track.py index 4cf2ed5..12c15f7 100644 --- a/devine/core/tracks/track.py +++ b/devine/core/tracks/track.py @@ -1,6 +1,7 @@ import asyncio import logging import re +import shutil import subprocess from enum import Enum from pathlib import Path @@ -312,7 +313,8 @@ class Track: if not self.path: return False target = Path(target) - ok = self.path.rename(target).resolve() == target.resolve() + + ok = Path(shutil.move(self.path, target)).resolve() == target.resolve() if ok: self.path = target return ok @@ -326,7 +328,7 @@ class Track: if not target.exists() or not self.path: return False self.path.unlink() - ok = target.rename(self.path) == self.path + ok = Path(shutil.move(target, self.path)).resolve() == self.path.resolve() if not ok: return False return self.move(target) From f06ca768c3daea1fbf8958aefe86cc67a325f52c Mon Sep 17 00:00:00 2001 From: rlaphoenix Date: Mon, 13 Feb 2023 18:33:51 +0000 Subject: [PATCH 2/2] Add varyg1001 to the Contributors list --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index acf66cb..ae1bfbc 100644 --- a/README.md +++ b/README.md @@ -291,6 +291,7 @@ Please refrain from spam or asking for questions that infringe upon a Service's + ## License