penguin/golifehk

@golifehk bot in Telegram

commit c22cdac1cbfc5d1d562230ee860a601c9577cad1

author斟酌 鵬兄 <tgckpg@gmail.com>
date2023-12-12T22:25:49Z
subjectFixed file not found error
commit c22cdac1cbfc5d1d562230ee860a601c9577cad1
Author: 斟酌 鵬兄 <tgckpg@gmail.com>
Date:   2023-12-12T22:25:49Z

    Fixed file not found error
---
 datasources/mtr/bus/busschedule.go | 13 +++++--------
 utils/cache.go                     |  2 +-
 2 files changed, 6 insertions(+), 9 deletions(-)

diff --git a/datasources/mtr/bus/busschedule.go b/datasources/mtr/bus/busschedule.go
index 7e708fd..12f3704 100644
--- a/datasources/mtr/bus/busschedule.go
+++ b/datasources/mtr/bus/busschedule.go
@@ -122,14 +122,11 @@ func getSchedule( lang string, routeName string ) ( *BusSchedule, error ) {
             return &newSch, nil
         }
 
-        if oldSch.Status == 0 && cs.NotExpired( 60 ) {
-            log.Printf( "Using cache: %s", CACHE_PATH )
-            return &oldSch, nil
-        }
-
-        if oldSch.StatusTime.Time == newSch.StatusTime.Time {
-            log.Printf( "Using cache: %s", CACHE_PATH )
-            return &oldSch, nil
+        if oldSch.Status == 0 {
+            if cs.NotExpired( 60 ) || oldSch.StatusTime.Time == newSch.StatusTime.Time {
+                log.Printf( "Using cache: %s", CACHE_PATH )
+                return &oldSch, nil
+            }
         }
 
         // First time + try again i times
diff --git a/utils/cache.go b/utils/cache.go
index a47a95e..e2131ca 100644
--- a/utils/cache.go
+++ b/utils/cache.go
@@ -73,7 +73,7 @@ func CacheStreamEx( path string, readStream func() ( io.ReadCloser, error ) ) (
         }
     }
 
-    return &cs, err
+    return &cs, nil
 }