Repository: pymedusa/Medusa

Issue:
[APP SUBMITTED]: IOError: [Errno 2] No such file or directory: u'/srv/media/downloads/Shokugeki.no.Soma.S03E23.VOSTFR.720p.WEBRiP.x264-GODSPACE.mkv'

### INFO
**Python Version**: `2.7.9 (default, Jun 29 2016, 13:08:31) [GCC 4.9.2]`
**Operating System**: `Linux-3.16.0-5-amd64-x86_64-with-debian-8.10`
**Locale**: `UTF-8`
**Branch**: [master](../tree/master)
**Database**: `44.11`
**Commit**: pymedusa/Medusa@c65ca2607fae74405dcceaaf8c02f3d29d0313ea
**Link to Log**: https://gist.github.com/00f5e3d7f6cb8c0656e338624c087ae5
### ERROR
<pre>
2018-06-18 16:04:10 ERROR    Thread_15 :: [c65ca26] Environment error: [Errno 2] No such file or directory: u'/srv/media/downloads/Shokugeki.no.Soma.S03E23.VOSTFR.720p.WEBRiP.x264-GODSPACE.mkv'
Traceback (most recent call last):
  File "/srv/medusa/<a href="../blob/c65ca2607fae74405dcceaaf8c02f3d29d0313ea/medusa/server/web/core/base.py#L283">medusa/server/web/core/base.py</a>", line 283, in async_call
    result = function(**kwargs)
  File "/srv/medusa/<a href="../blob/c65ca2607fae74405dcceaaf8c02f3d29d0313ea/medusa/server/web/home/handler.py#L2165">medusa/server/web/home/handler.py</a>", line 2165, in doRename
    root_ep_obj.rename()
  File "/srv/medusa/<a href="../blob/c65ca2607fae74405dcceaaf8c02f3d29d0313ea/medusa/tv/episode.py#L1847">medusa/tv/episode.py</a>", line 1847, in rename
    self.location).list_associated_files(app.SUBTITLES_DIR, subfolders=True, subtitles_only=True)
  File "/srv/medusa/<a href="../blob/c65ca2607fae74405dcceaaf8c02f3d29d0313ea/medusa/post_processor.py#L208">medusa/post_processor.py</a>", line 208, in list_associated_files
    processed_names += tuple((_f for _f in (self._rar_basename(file_path, files),) if _f))
  File "/srv/medusa/<a href="../blob/c65ca2607fae74405dcceaaf8c02f3d29d0313ea/medusa/post_processor.py#L318">medusa/post_processor.py</a>", line 318, in _rar_basename
    for rar in rars:
  File "/srv/medusa/<a href="../blob/c65ca2607fae74405dcceaaf8c02f3d29d0313ea/medusa/post_processor.py#L316">medusa/post_processor.py</a>", line 316, in <genexpr>
    rars = (x for x in files if rarfile.is_rarfile(x))
  File "/srv/medusa/<a href="../blob/c65ca2607fae74405dcceaaf8c02f3d29d0313ea/medusa/init/filesystem.py#L113">medusa/init/filesystem.py</a>", line 113, in patched_output
    return handle_output(f(*args, **kwargs))
  File "/srv/medusa/<a href="../blob/c65ca2607fae74405dcceaaf8c02f3d29d0313ea/ext/rarfile.py#L404">ext/rarfile.py</a>", line 404, in is_rarfile
    return _get_rar_version(xfile) > 0
  File "/srv/medusa/<a href="../blob/c65ca2607fae74405dcceaaf8c02f3d29d0313ea/ext/rarfile.py#L389">ext/rarfile.py</a>", line 389, in _get_rar_version
    with XFile(xfile) as fd:
  File "/srv/medusa/<a href="../blob/c65ca2607fae74405dcceaaf8c02f3d29d0313ea/ext/rarfile.py#L2401">ext/rarfile.py</a>", line 2401, in __init__
    self._fd = open(xfile, 'rb', bufsize)
IOError: [Errno 2] No such file or directory: u'/srv/media/downloads/Shokugeki.no.Soma.S03E23.VOSTFR.720p.WEBRiP.x264-GODSPACE.mkv'
</pre>
---
_STAFF NOTIFIED_: @pymedusa/support @pymedusa/moderators



Discussion:

Resolving patch:
diff --git a/medusa/post_processor.py b/medusa/post_processor.py
--- a/medusa/post_processor.py
+++ b/medusa/post_processor.py
@@ -319,7 +319,7 @@ def _search_files(path, pattern='*', subfolders=False, basename_only=False, sort
     def _rar_basename(file_path, files):
         """Return the lowercase basename of the source rar archive if found."""
         videofile = os.path.basename(file_path)
-        rars = (x for x in files if rarfile.is_rarfile(x))
+        rars = (x for x in files if os.path.isfile(x) and rarfile.is_rarfile(x))
 
         for rar in rars:
             try:


Test patch: