Добавлен helper - get_dir_diagnostics туда вынесены проверки прав доступ
This commit is contained in:
@ -32,6 +32,22 @@ log_collision() {
|
||||
echo "[$(timestamp)] [SKIP] Collision: $1" >> "$LOG_FILE"
|
||||
}
|
||||
|
||||
get_dir_diagnostics() {
|
||||
local DIR="$1"
|
||||
|
||||
local DIR_STAT
|
||||
DIR_STAT=$(stat -c 'inode=%i uid=%u gid=%g perms=%a owner=%U group=%G' "$DIR" 2>/dev/null)
|
||||
|
||||
cat <<EOF
|
||||
dir_stat='$DIR_STAT'
|
||||
|
||||
current_user='$(id -un)'
|
||||
current_group='$(id -gn)'
|
||||
current_uid='$(id -u)'
|
||||
current_gid='$(id -g)'
|
||||
EOF
|
||||
}
|
||||
|
||||
# Логируем новую задачу
|
||||
log_info "----------------------------------------------"
|
||||
log_info "Torrent: $1"
|
||||
@ -195,10 +211,7 @@ if [[ $2 == 'Anime' ]]; then
|
||||
log_error "Failed to create target directory
|
||||
|
||||
Path='$TARGET_DIR'
|
||||
current_user='$(id -un)'
|
||||
current_group='$(id -gn)'
|
||||
current_uid='$(id -u)'
|
||||
current_gid='$(id -g)'"
|
||||
$(get_dir_diagnostics "$TARGET_DIR")"
|
||||
|
||||
continue
|
||||
fi
|
||||
@ -210,18 +223,11 @@ current_gid='$(id -g)'"
|
||||
|
||||
if [ ! -w "$TARGET_DIR" ]; then
|
||||
|
||||
DST_DIR_STAT=$(stat -c 'inode=%i uid=%u gid=%g perms=%a owner=%U group=%G' "$TARGET_DIR" 2>/dev/null)
|
||||
|
||||
log_error "Target directory is not writable
|
||||
|
||||
Source='$FILE_PATH'
|
||||
Target='$TARGET_FILE'
|
||||
target_dir_stat='$DST_DIR_STAT'
|
||||
|
||||
current_user='$(id -un)'
|
||||
current_group='$(id -gn)'
|
||||
current_uid='$(id -u)'
|
||||
current_gid='$(id -g)'"
|
||||
$(get_dir_diagnostics "$TARGET_DIR")"
|
||||
|
||||
continue
|
||||
fi
|
||||
@ -247,7 +253,6 @@ current_gid='$(id -g)'"
|
||||
LN_ERROR=$(cat "$TMP_ERR" 2>/dev/null)
|
||||
|
||||
SRC_STAT=$(stat -c 'inode=%i uid=%u gid=%g perms=%a owner=%U group=%G' "$FILE_PATH" 2>/dev/null)
|
||||
DST_DIR_STAT=$(stat -c 'inode=%i uid=%u gid=%g perms=%a owner=%U group=%G' "$TARGET_DIR" 2>/dev/null)
|
||||
|
||||
log_error "Link failed for '$FINAL_FILENAME'
|
||||
|
||||
@ -257,12 +262,8 @@ Target='$TARGET_FILE'
|
||||
ln_error='$LN_ERROR'
|
||||
|
||||
source_stat='$SRC_STAT'
|
||||
target_dir_stat='$DST_DIR_STAT'
|
||||
|
||||
current_user='$(id -un)'
|
||||
current_group='$(id -gn)'
|
||||
current_uid='$(id -u)'
|
||||
current_gid='$(id -g)'"
|
||||
$(get_dir_diagnostics "$TARGET_DIR")"
|
||||
|
||||
fi
|
||||
|
||||
|
||||
Reference in New Issue
Block a user