]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
media_cache: Mark cache entry stale if cache file is removed
authorSean Bright <sean.bright@gmail.com>
Tue, 28 Feb 2017 19:48:51 +0000 (14:48 -0500)
committerSean Bright <sean.bright@gmail.com>
Tue, 28 Feb 2017 19:56:04 +0000 (14:56 -0500)
In the event that a cache file is removed out from under us, we should
treat the cache entry as stale and force a refresh.

ASTERISK-26774 #close
Reported by: Igor Gamayunov

Change-Id: I3b1bd0c999d59d18664ef73a29823bc5b431dc52

main/media_cache.c

index 958a05bb254e5baed38a86934709a7a7393a35a8..4d1cf546a6613332552c9e312a2dc44990c95e95 100644 (file)
@@ -226,7 +226,8 @@ int ast_media_cache_retrieve(const char *uri, const char *preferred_file_name,
         */
        bucket_file = ao2_find(media_cache, uri, OBJ_SEARCH_KEY | OBJ_NOLOCK);
        if (bucket_file) {
-               if (!ast_bucket_file_is_stale(bucket_file)) {
+               if (!ast_bucket_file_is_stale(bucket_file)
+                       && !access(bucket_file->path, R_OK)) {
                        ast_copy_string(file_path, bucket_file->path, len);
                        if ((ext = strrchr(file_path, '.'))) {
                                *ext = '\0';