소스 검색

fix null access if key not in cache

Mike L 3 년 전
부모
커밋
53392060cb
2개의 변경된 파일2개의 추가작업 그리고 2개의 파일을 삭제
  1. 1 1
      dist/twitter.js
  2. 1 1
      src/twitter.ts

+ 1 - 1
dist/twitter.js

@@ -303,7 +303,7 @@ class default_1 {
                 lock.threads[currentFeed].subscribers.length === 0) {
                 logger.warn(`nobody subscribes thread ${currentFeed}, removing from feed`);
                 delete lock.threads[currentFeed];
-                this.cache[parseLink(currentFeed).userName].pullOrder = 0;
+                (this.cache[parseLink(currentFeed).userName] || {}).pullOrder = 0;
                 lock.feed.splice(lock.workon, 1);
                 fs.writeFileSync(path.resolve(this.lockfile), JSON.stringify(lock));
                 this.work();

+ 1 - 1
src/twitter.ts

@@ -521,7 +521,7 @@ export default class {
       lock.threads[currentFeed].subscribers.length === 0) {
       logger.warn(`nobody subscribes thread ${currentFeed}, removing from feed`);
       delete lock.threads[currentFeed];
-      this.cache[parseLink(currentFeed).userName].pullOrder = 0;
+      (this.cache[parseLink(currentFeed).userName] || {} as {pullOrder: number}).pullOrder = 0;
       lock.feed.splice(lock.workon, 1);
       fs.writeFileSync(path.resolve(this.lockfile), JSON.stringify(lock));
       this.work();