Add more check

This commit is contained in:
sxyazi 2024-01-11 13:40:35 +08:00
parent a1339aad2b
commit 6809e9dcef
No known key found for this signature in database
3 changed files with 21 additions and 7 deletions

View file

@ -1,8 +1,12 @@
local M = {} local M = {}
function M:peek() function M:peek()
local cache = ya.file_cache(self) local url = ya.file_cache(self)
ya.image_show(fs.symlink_metadata(cache) and cache or self.file.url, self.area) if not url or not fs.symlink_metadata(url) then
url = self.file.url
end
ya.image_show(url, self.area)
ya.preview_widgets(self, {}) ya.preview_widgets(self, {})
end end
@ -10,7 +14,7 @@ function M:seek() end
function M:preload() function M:preload()
local cache = ya.file_cache(self) local cache = ya.file_cache(self)
if fs.symlink_metadata(cache) then if not cache or fs.symlink_metadata(cache) then
return 1 return 1
end end

View file

@ -1,8 +1,13 @@
local M = {} local M = {}
function M:peek() function M:peek()
local cache = ya.file_cache(self)
if not cache then
return
end
if self:preload() == 1 then if self:preload() == 1 then
ya.image_show(ya.file_cache(self), self.area) ya.image_show(cache, self.area)
ya.preview_widgets(self, {}) ya.preview_widgets(self, {})
end end
end end
@ -17,7 +22,7 @@ end
function M:preload() function M:preload()
local cache = ya.file_cache(self) local cache = ya.file_cache(self)
if fs.symlink_metadata(cache) then if not cache or fs.symlink_metadata(cache) then
return 1 return 1
end end

View file

@ -1,8 +1,13 @@
local M = {} local M = {}
function M:peek() function M:peek()
local cache = ya.file_cache(self)
if not cache then
return
end
if self:preload() == 1 then if self:preload() == 1 then
ya.image_show(ya.file_cache(self), self.area) ya.image_show(cache, self.area)
ya.preview_widgets(self, {}) ya.preview_widgets(self, {})
end end
end end
@ -25,7 +30,7 @@ function M:preload()
end end
local cache = ya.file_cache(self) local cache = ya.file_cache(self)
if fs.symlink_metadata(cache) then if not cache or fs.symlink_metadata(cache) then
return 1 return 1
end end