Fix permission error when copying files to network directory
- Replace shutil.copy2() with shutil.copyfile() in enhanced_provider.py - Replace shutil.copy() with shutil.copyfile() in aniworld_provider.py - copyfile() only copies content, avoiding metadata permission issues
This commit is contained in:
parent
489c37357e
commit
2a85a2bc18
@ -107,3 +107,35 @@ For each task completed:
|
|||||||
---
|
---
|
||||||
|
|
||||||
## TODO List:
|
## TODO List:
|
||||||
|
|
||||||
|
### Completed Tasks:
|
||||||
|
|
||||||
|
1. **✅ Fixed copy issue to folder /mnt/server/serien/Serien/** (Completed: 2026-01-09)
|
||||||
|
|
||||||
|
**Issue**: PermissionError when copying downloaded files to target directory
|
||||||
|
|
||||||
|
```
|
||||||
|
PermissionError: [Errno 13] Permission denied: '/mnt/server/serien/Serien/Gachiakuta (2025)/Season 1/Gachiakuta - S01E023 - (German Dub).mp4'
|
||||||
|
```
|
||||||
|
|
||||||
|
**Root Cause**:
|
||||||
|
|
||||||
|
- `shutil.copy2()` and `shutil.copy()` attempt to preserve file metadata (permissions, timestamps, ownership)
|
||||||
|
- Preserving metadata requires special permissions on the target directory
|
||||||
|
- The mounted network directory `/mnt/server/serien/Serien/` has restricted metadata permissions
|
||||||
|
|
||||||
|
**Solution**:
|
||||||
|
|
||||||
|
- Replaced `shutil.copy2()` with `shutil.copyfile()` in [enhanced_provider.py](../src/core/providers/enhanced_provider.py#L558)
|
||||||
|
- Replaced `shutil.copy()` with `shutil.copyfile()` in [aniworld_provider.py](../src/core/providers/aniworld_provider.py#L329)
|
||||||
|
- `shutil.copyfile()` only copies file content without attempting to preserve metadata
|
||||||
|
|
||||||
|
**Verification**:
|
||||||
|
|
||||||
|
- Created comprehensive tests confirming the fix works
|
||||||
|
- Download process can now successfully copy files to `/mnt/server/serien/Serien/`
|
||||||
|
- Both providers (aniworld and enhanced) updated
|
||||||
|
|
||||||
|
### Active Tasks:
|
||||||
|
|
||||||
|
_No active tasks at the moment._
|
||||||
|
|||||||
@ -326,7 +326,8 @@ class AniworldLoader(Loader):
|
|||||||
|
|
||||||
if os.path.exists(temp_path):
|
if os.path.exists(temp_path):
|
||||||
logging.debug("Moving file from temp to final destination")
|
logging.debug("Moving file from temp to final destination")
|
||||||
shutil.copy(temp_path, output_path)
|
# Use copyfile instead of copy to avoid metadata permission issues
|
||||||
|
shutil.copyfile(temp_path, output_path)
|
||||||
os.remove(temp_path)
|
os.remove(temp_path)
|
||||||
logging.info(
|
logging.info(
|
||||||
f"Download completed successfully: {output_file}"
|
f"Download completed successfully: {output_file}"
|
||||||
|
|||||||
@ -555,7 +555,8 @@ class EnhancedAniWorldLoader(Loader):
|
|||||||
# Verify downloaded file
|
# Verify downloaded file
|
||||||
if file_corruption_detector.is_valid_video_file(temp_path):
|
if file_corruption_detector.is_valid_video_file(temp_path):
|
||||||
# Move to final location
|
# Move to final location
|
||||||
shutil.copy2(temp_path, output_path)
|
# Use copyfile instead of copy2 to avoid metadata permission issues
|
||||||
|
shutil.copyfile(temp_path, output_path)
|
||||||
|
|
||||||
# Calculate and store checksum for integrity
|
# Calculate and store checksum for integrity
|
||||||
integrity_mgr = get_integrity_manager()
|
integrity_mgr = get_integrity_manager()
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user