Repository: pymedusa/Medusa

Issue:
Mass Update Fails
### Before submitting your issue:

Enable debug logging in Medusa settings, reproduce the error (be sure to disable after the bug is fixed)

**Branch/Commit:** develop/f91e7a366cc140c97abf81aaed9269d54e1b85e3
**OS:** Linux-4.12.3-feral-x86_64-with-debian-8.8
**What you did:** Mass update to change all media base path.
**What happened:** fails
**What you expected:** path to change
**Logs:**
```
2017-10-15 17:02:36 ERROR    Thread-21 :: [f91e7a3] Exception generated: Show folder does not exist.
Traceback (most recent call last):
  File "/media/sdu1/home/**********/.medusa/medusa/server/web/core/base.py", line 258, in async_call
    result = function(**kwargs)
  File "/media/sdu1/home/**********/.medusa/medusa/server/web/manage/handler.py", line 585, in massEditSubmit
    (show=show_obj, location=new_show_dir))  # pylint: di**********le=protected-access
  File "/media/sdu1/home/**********/.medusa/medusa/tv/series.py", line 368, in location
    raise ShowDirectoryNotFoundException(u'Show folder does not exist.')
ShowDirectoryNotFoundException: Show folder does not exist.
```
Also i tried with a single show via mass update and it gets the same error. Going in the show and just changing the path works. Also i had already moved all Videos to the new path.


Discussion:
Happening to me too upon moving to the docker image where I have to re-base my file locations using /tv. 
Seems the logic isn't actually changing the root directory as expected in ```medusa/server/web/manage/handler.py```

```
            cur_root_dir = os.path.dirname(show_obj._location)  # pylint: disable=protected-access
            cur_show_dir = os.path.basename(show_obj._location)  # pylint: disable=protected-access
            if cur_root_dir in dir_map and cur_root_dir != dir_map[cur_root_dir]:
                new_show_dir = os.path.join(dir_map[cur_root_dir], cur_show_dir)
                logger.log(u'For show {show.name} changing dir from {show.location} to {location}'.format
                           (show=show_obj, location=new_show_dir))  # pylint: disable=protected-access
            else:
                new_show_dir = show_obj._location  # pylint: disable=protected-access
```
Seems like the new_show_dir should be using the end_dir variable from earlier.
@medariox @p0psicles 

Has this been fixed yet? I have 200+ shows to fix and doing them one by one is going to be real painful
Still seems to be broken :(

```
2018-01-15 07:54:16 ERROR    Thread-46 :: [1536629] Exception generated: Show folder does not exist.
Traceback (most recent call last):
  File "/home28/**********/software/Medusa/medusa/server/web/core/base.py", line 280, in async_call
    result = function(**kwargs)
  File "/home28/**********/software/Medusa/medusa/server/web/manage/handler.py", line 598, in massEditSubmit
    (show=show_obj, location=new_show_dir))  # pylint: disable=protected-access
  File "/home28/**********/software/Medusa/medusa/tv/series.py", line 368, in location
    raise ShowDirectoryNotFoundException(u'Show folder does not exist.')
ShowDirectoryNotFoundException: Show folder does not exist.

```
@saitoh183 did you enabled the setting in PP to create show folder if it doesn't exist?
@medariox can you please check @bobbysteel comment: https://github.com/pymedusa/Medusa/issues/3160#issuecomment-340186688 ?
All these comments and I don't see a single debug log. No debug logs, no fix.
I turned on debug and the error I posted was all that I got. The path and folder exist
Maybe we need more then the error. That's why we ask for the full debug logs. 
When i modify paths and hit save, it loads a blank screen. When i check the last thing in the log, that is the error i see and when i switch it to debug, i didnt see anything more at with the same timestamp as the error hence why i didnt post anything more. But here all the logs.
[logs.zip](https://github.com/pymedusa/Medusa/files/1631899/logs.zip)

You forgot to mention the warnings:
```
2018-01-15 07:53:49 WARNING  Thread-26 :: [1536629] Unable to open /home28: OSError(13, 'Permission denied') / [Errno 13] Permission denied: '/home28'
```

Check your permissions on the folders.
i cant modify the permissions because im not root and this is a seedbox...i dont have access to see inside /home28...only /home28/saitoh183. I tried it on sickrage and it works without a problem
Im able to add a new show without a problem
If i modify the path individually, it also works
What is your full current root path and what is the full path you are trying to switch to?
/media/sdu1/home/saitoh183/private/Videos/TV/ (doesnt exist...path on previous seedbox)
/home28/saitoh183/Videos/TV/ (new path )
Also since my OP the medusa version is changed

![image](https://user-images.githubusercontent.com/1534197/34952488-e2d16750-f9e7-11e7-84da-f641b02b6977.png)


Resolving patch:
diff --git a/medusa/server/web/manage/handler.py b/medusa/server/web/manage/handler.py
--- a/medusa/server/web/manage/handler.py
+++ b/medusa/server/web/manage/handler.py
@@ -590,14 +590,14 @@ def massEditSubmit(self, paused=None, default_ep_status=None, dvd_order=None,
             if not show_obj:
                 continue
 
-            cur_root_dir = os.path.dirname(show_obj._location)  # pylint: disable=protected-access
-            cur_show_dir = os.path.basename(show_obj._location)  # pylint: disable=protected-access
+            cur_root_dir = os.path.dirname(show_obj._location)
+            cur_show_dir = os.path.basename(show_obj._location)
             if cur_root_dir in dir_map and cur_root_dir != dir_map[cur_root_dir]:
                 new_show_dir = os.path.join(dir_map[cur_root_dir], cur_show_dir)
-                logger.log(u'For show {show.name} changing dir from {show.location} to {location}'.format
-                           (show=show_obj, location=new_show_dir))  # pylint: disable=protected-access
+                logger.log(u'For show {show.name} changing dir from {show._location} to {location}'.format
+                           (show=show_obj, location=new_show_dir))
             else:
-                new_show_dir = show_obj._location  # pylint: disable=protected-access
+                new_show_dir = show_obj._location
 
             if paused == 'keep':
                 new_paused = show_obj.paused


Test patch: