Kodi Community Forum

Full Version: Add on updates fail when temp and addons are on different file systems
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I have ~/.kodi/temp and ~/.kodi/addons on different file systems. ~/.kodi and ~/.kodi/addons are on the same file system and ~/.kodi/temp is on a different one (I keep temp on a different file system because I don't want to include it my btrfs snapshots).

Both ~/.kodi/[addons,temp] have the same file system permissions:
drwxr-xr-x 1 mythtv users

(I run kodi as the user "mythtv").

Whenever Kodi attempts to update any addon, it fails. Here's an example excerpt from ~/.kodi/temp/kodi.log:
Code:
21:05:07 T:139855379003136   DEBUG: Unpacking zip://special%3A%2F%2Fhome%2Faddons%2Fpackages%2Fresource.language.en_us-3.0.2.zip/resource.language.en_us/ to /home/mythtv/.kodi/temp/a11290a5-cdd3-4d2d-9681-14102b94326f
21:05:07 T:139855379003136   DEBUG: Rename: Source file "/home/mythtv/.kodi/addons/resource.language.en_us" and target file "/home/mythtv/.kodi/temp/94fb4cac-bfbf-4f54-928e-b0d2ef8c928e" are located on different filesystems, copy&delete will be used instead of rename
21:05:07 T:139855379003136   ERROR: Copy - Failed read from file /home/mythtv/.kodi/addons/resource.language.en_us
21:05:07 T:139855379003136   ERROR: Rename - Error renaming file /home/mythtv/.kodi/addons/resource.language.en_us
21:05:07 T:139855379003136   ERROR: Failed to move old addon files from '/home/mythtv/.kodi/addons/resource.language.en_us' to '/home/mythtv/.kodi/temp/94fb4cac-bfbf-4f54-928e-b0d2ef8c928e'

Permissions of "/home/mythtv/.kodi/addons/resource.language.en_us" which the logs say "failed read":
Code:
$ ls -la /home/mythtv/.kodi/addons/resource.language.en_us
total 8
drwxr-xr-x 1 mythtv users   52 Jul 22 19:49 .
drwxr-xr-x 1 mythtv users 7918 Nov  2 00:16 ..
-rw-r--r-- 1 mythtv users  701 Jul 22 19:49 addon.xml
-rw-r--r-- 1 mythtv users 1994 Jul 22 19:49 icon.png
drwxr-xr-x 1 mythtv users   44 Jul 22 19:49 resources

If I su to the "mythtv" user, I can rename, copy, delete, etc the "/home/mythtv/.kodi/addons/resource.language.en_us" directory fine.

Note that Kodi can and does write to ~/.kodi/temp - there are plenty of files and directories in there. If I make ~/.kodi/temp a directory on the same file system as ~/.kodi, then addons upgrade fine. Therefore, I suspect there's a problem with the code that does "copy&delete will be used instead of rename" - but maybe I'm doing something wrong?

I'm using Kodi 17 post beta 5 (git commit c05fc78) built today.

Thanks in advance for the assistance.
It looks like the problem is that Kodi is trying to copy the directory as if it were a file.

At https://github.com/xbmc/xbmc/blob/c05fc7...e.cpp#L325 this method is called:
Code:
XFILE::CFile::Copy("/home/mythtv/.kodi/addons/resource.language.en_us", "/home/mythtv/.kodi/temp/94fb4cac-bfbf-4f54-928e-b0d2ef8c928e")
Which leads to https://github.com/xbmc/xbmc/blob/c05fc7...e.cpp#L158 where the "Failed read from file" message is logged, which happened because it's trying to read bytes from the file "/home/mythtv/.kodi/addons/resource.language.en_us" (which is a problem because that's a directory, not a file).

It seems that CFile::Copy needs to see if the input file is a directory, and if so, traverse the directory tree copying the files and directories within it.
Created http://trac.kodi.tv/ticket/17049 for this issue.