Skip to content
View in the app

A better way to browse. Learn more.

Unraid

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Protecting files from deletion by iTunes

Featured Replies

Hello,

Recently iTunes has started deleting my podcasts in a rather random way ... might be filename related. 
 

iTunes will download free content, then randomly delete certain files ... it always seems to end up deleting the same ones and keeping the same others. 
 

I started tracking changes in my iTunes share Via inotifywait and hoped if I did a chmod a-w on newly downloaded files after a CLOSE event I could stop iTunes from deleting them. 
 

The share is secure setting security with the iTunes user having read/write permissions. 
 

Fewer files are getting deleted, but the permissions change hasn’t stopped them disappearing. 
 

How do I stop iTunes from deleting files in this share after the writable permission has been cleared?

 

thanks for your time,

Bobby 

I do the following for files I want to be protected against all forms of modifcation (make it read-only for everyone, make it owned by user root and group root, and make it immutable to change). The change-attribute command does not work through fuse ie: /mnt/user/ or /mnt/user0/ .

 

chmod 444 /mnt/disk#/share/dir/subdir/filename

chown root.root /mnt/disk#/share/dir/subdir/filename

chattr +i /mnt/disk#/share/dir/subdir/filename

 

To make it able to be changed again:

 

chattr -i /mnt/disk#/share/dir/subdir/filename

 

  • Author

Thank you for your help

 

just discovered shellcheck.net the other day ... helps me greatly. 

 

I’ll  give it a try

yes I was changing the permissions on the fuse file system, my mistake. 

 

Can I do this to files on the cache drive? And then will the mover still be able to move the files?
 

if not I’ll change it so the share is set to skip the cache drive. 

Edited by perfessor101

  • Author

I've got this far ... this command gives me the format and data I want in a form I can hopefully pass on to the permissions part ...

using '?' as a separator as the filenames have spaces and it looked like one of the only characters not used in filenames.

inotifywait -e close -mr --format '%T?%e?/mnt/disk5/music/iTunes/iTunes Media/%w?%f?' --timefmt '%D-%T'  'Podcasts/' |
        grep -v 'ISDIR'

when I try expanding it to this ... it doesn't work and I'm not sure how to track down where its broken ...

 

inotifywait -e close -mr --format '%T?%e?/mnt/disk5/music/iTunes/iTunes Media/%w?%f?' --timefmt '%D-%T'  'Podcasts/' |
        grep -v 'ISDIR' |
        while IFS='?' read -r datetime action mypath file1; do
             echo "  Date: "$datetime
             echo "Action: "$action
             echo "  Path: "$mypath
             echo " File1: "$file1
             echo "cd "$mypath
             cd $mypath
             echo "chmod -c a-w "$file1
             chmod -c a-w $file1
             printf '\n'
    done

Thanks for your time and help,

Bobby

  • Author

okay flipping some things around after much googling ... 

this appears to work 

 

I should just ask on fiver for these scripts ...

 

now to try to get it to do something with the files ...

 

#!/bin/bash

cd /mnt/disk5/music/iTunes/
cd iTunes\ Media/
pwd
echo " $(date) "

while IFS='?' read -r datetime action mypath file1; do
    if [[ "$(echo "$action" | tr '[:upper:]' '[:lower:]')" != *"isdir"* ]] ; then
        if [[ "$(echo "$file1" | tr '[:upper:]' '[:lower:]')" != *"download.mp3"* ]] ; then
            echo "  Date: '$datetime'"
            echo "Action: '$action'"
            echo "  Path: '$mypath'"
            echo " File1: '$file1'"
            printf '\n'
            fi
        fi
done < <(exec inotifywait -e close -mr --format '%T?%e?/mnt/disk5/music/iTunes/iTunes Media/%w?%f?' --timefmt '%D-%T'  'Podcasts/')


 

Edited by perfessor101
full script so far

Archived

This topic is now archived and is closed to further replies.

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.