Skip to content

Commit

Permalink
Fix Documents, Pictures, Music etc are symlinks in (#220)
Browse files Browse the repository at this point in the history
* Fix Documents, Pictures, Music etc are symlinks in

When a user has one or several `XDG_SPECIAL_DIRS` folders symlinked in their real home folder to elsewhere in their real home folder `common/desktop-exports` will attempt to mv those folders to themselves.

* guard `mv` calls with test for `is_subpath` to ensure that we're only moving symlinks we created.

Signed-off-by: Daniel Llewellyn <diddledan@ubuntu.com>

* Redirect STDERR from readlink call in common/desktop-exports

If readlink fails, it will output on stderr.

* Throw away stderr

Signed-off-by: Daniel Llewellyn <diddledan@ubuntu.com>
  • Loading branch information
Daniel Llewellyn authored Feb 9, 2021
1 parent e3a13b8 commit 12c6ea6
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion common/desktop-exports
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,8 @@ else
for ((i = 0; i < ${#XDG_SPECIAL_DIRS[@]}; i++)); do
old="${XDG_SPECIAL_DIRS_INITIAL_PATHS[$i]}"
new="${XDG_SPECIAL_DIRS_PATHS[$i]}"
if [ -L "$old" ] && [ -d "$new" ] && [ `readlink "$old"` != "$new" ]; then
if [ -L "$old" ] && [ -d "$new" ] && [ `readlink "$old" 2>/dev/null` != "$new" ] &&
(is_subpath "$old" "$SNAP_USER_DATA" || is_subpath "$old" "$SNAP_USER_COMMON"); then
mv -vn "$old"/* "$new"/ 2>/dev/null
elif [ -d "$old" ] && [ -d "$new" ] && [ "$old" != "$new" ] &&
(is_subpath "$old" "$SNAP_USER_DATA" || is_subpath "$old" "$SNAP_USER_COMMON"); then
Expand Down

0 comments on commit 12c6ea6

Please sign in to comment.