filecat 5.18.8 → 5.18.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1 @@
1
+ (()=>{"use strict";var e={167(e){e.exports=require("worker_threads")},285(e,t,r){var n=this&&this.__awaiter||function(e,t,r,n){return new(r||(r=Promise))(function(o,a){function s(e){try{c(n.next(e))}catch(e){a(e)}}function i(e){try{c(n.throw(e))}catch(e){a(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r(function(e){e(t)})).then(s,i)}c((n=n.apply(e,t||[])).next())})};Object.defineProperty(t,"__esModule",{value:!0}),t.file_search_start=function(){(0,o.register_threads_worker_handler)(a.threads_msg_type.file_search,e=>n(this,void 0,void 0,function*(){const{start:t,end:r,file_path:n,query_text_buffer:_,ram_id:l}=e.data;let h=0,f=Buffer.alloc(0);const u=s.openSync(n,"r");let p=0;for(;h<r&&!d[l];){const e=Buffer.alloc(2097152);let t=s.readSync(u,e,0,e.length,h);if(0===t)break;h+=t,f=Buffer.concat([f,e.subarray(0,t)]),(0,o.threads_send)({type:a.threads_msg_type.search_file_progress,data:{progress:(100*h/r).toFixed(0),ram_id:l}});const n=[];if(c(f,_,n),n.length>0){for(let e=0;e<n.length;e++)n[e]+=p;(0,o.threads_send)({type:a.threads_msg_type.search_file_index,data:{find_index:n,ram_id:l}})}p+=f.length-_.length,f=i(f,f.length-_.length,f.length)}return(0,o.threads_send)({type:a.threads_msg_type.search_file_end,data:{ram_id:l}}),s.closeSync(u),"ok"})),(0,o.register_threads_worker_handler)(a.threads_msg_type.file_search_close,e=>n(this,void 0,void 0,function*(){const{ram_id:t}=e.data;return d[t]=!0,"ok"})),(0,o.register_threads_worker_handler)(a.threads_msg_type.file_search_start,e=>n(this,void 0,void 0,function*(){const{ram_id:t}=e.data;return delete d[t],"ok"}))};const o=r(324),a=r(525),s=r(896);function i(e,t,r){const n=r-t,o=Buffer.alloc(n);return e.copy(o,0,t,r),o}function c(e,t,r){const n=function(e){const t={},r=e.length;for(let n=0;n<r;n++)t[e[n]]=n;return t}(t),o=e.length,a=t.length,s=o-a;let i=0;for(;i<=s;){let s=a-1;for(;s>=0&&e[i+s]===t[s];)s--;if(s<0)r.push(i),i+=i+a<o?a-n[e[i+a]]||a:1;else{const t=n[e[i+s]],r=void 0!==t?s-t:s+1;i+=Math.max(r,1)}}}const d={}},324(e,t,r){var n=this&&this.__awaiter||function(e,t,r,n){return new(r||(r=Promise))(function(o,a){function s(e){try{c(n.next(e))}catch(e){a(e)}}function i(e){try{c(n.throw(e))}catch(e){a(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r(function(e){e(t)})).then(s,i)}c((n=n.apply(e,t||[])).next())})};Object.defineProperty(t,"__esModule",{value:!0}),t.register_threads_worker_handler=c,t.threads_send=d;const o=r(167),a=r(525),s=r(285);console.log("[worker] 子线程启动, workerData=",o.workerData);const i=new Map;function c(e,t){i.set(e,t)}function d(e){try{null===o.parentPort||void 0===o.parentPort||o.parentPort.postMessage(e)}catch(e){console.error("[worker] send failed:",e)}}null===o.parentPort||void 0===o.parentPort||o.parentPort.on("message",e=>{!function(e){n(this,void 0,void 0,function*(){try{const t=i.get(e.type);if(!t)return void d({id:e.id,type:e.type,data:`unknown type ${e.type}`});const r=yield t(e);d({id:e.id,type:e.type,data:r})}catch(t){d({id:e.id,type:e.type,data:null,error:(null==t?void 0:t.message)||String(t)}),console.error("[worker] task error:",t)}})}(e)}),c(a.threads_msg_type.hello,e=>n(void 0,void 0,void 0,function*(){return new Promise((t,r)=>setTimeout(()=>{if(Math.random()<.05)return r(new Error("模拟错误"));t(`done:${e.data}`)},500))})),(0,s.file_search_start)(),console.log("[worker] ready and waiting for messages...")},525(e,t){var r;Object.defineProperty(t,"__esModule",{value:!0}),t.threads_msg_type=void 0,function(e){e[e.hello=1]="hello",e[e.file_search_start=2]="file_search_start",e[e.file_search=3]="file_search",e[e.file_search_close=4]="file_search_close",e[e.search_file_index=5]="search_file_index",e[e.search_file_progress=6]="search_file_progress",e[e.search_file_end=7]="search_file_end"}(r||(t.threads_msg_type=r={}))},896(e){e.exports=require("fs")}},t={};(function r(n){var o=t[n];if(void 0!==o)return o.exports;var a=t[n]={exports:{}};return e[n].call(a.exports,a,a.exports,r),a.exports})(324)})();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "filecat",
3
- "version": "5.18.8",
3
+ "version": "5.18.9",
4
4
  "description": "FileCat Server Manager",
5
5
  "author": "xiaobaidadada",
6
6
  "scripts": {
package/shell/build.js CHANGED
@@ -46,8 +46,8 @@ const tasksLister = new Listr(
46
46
  return Promise.all([new Promise((res, rej) => {
47
47
  // 第一个
48
48
  webpack(get_webpack_work_config({
49
- entry_path:path.join(__dirname, "..", "build", "server", "main","domain","file","search", "file.search.worker.js"),
50
- output_name:'file.search.worker.js',
49
+ entry_path:path.join(__dirname, "..", "build", "server", "main","threads","threads.work.js"),
50
+ output_name:'threads.work.js',
51
51
  pkg:args[0]==="npm",
52
52
  docker:args[0]==="docker",
53
53
  }), (err, stats) => {
@@ -1 +0,0 @@
1
- (()=>{"use strict";var e={167(e){e.exports=require("worker_threads")},285(e,t,n){var r=this&&this.__awaiter||function(e,t,n,r){return new(n||(n=Promise))(function(o,s){function c(e){try{l(r.next(e))}catch(e){s(e)}}function a(e){try{l(r.throw(e))}catch(e){s(e)}}function l(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(c,a)}l((r=r.apply(e,t||[])).next())})};Object.defineProperty(t,"__esModule",{value:!0});const o=n(167),s=n(896);function c(e,t,n){const r=n-t,o=Buffer.alloc(r);return e.copy(o,0,t,n),o}function a(e,t,n){const r=function(e){const t={},n=e.length;for(let r=0;r<n;r++)t[e[r]]=r;return t}(t),o=e.length,s=t.length,c=o-s;let a=0;for(;a<=c;){let c=s-1;for(;c>=0&&e[a+c]===t[c];)c--;if(c<0)n.push(a),a+=a+s<o?s-r[e[a+s]]||s:1;else{const t=r[e[a+c]],n=void 0!==t?c-t:c+1;a+=Math.max(n,1)}}}let l=!1;o.parentPort.on("message",e=>r(void 0,void 0,void 0,function*(){try{switch(e.type){case 1:{const{start:t,end:n,file_path:r,query_text_buffer:f}=e;let i=0,u=Buffer.alloc(0);const p=s.openSync(r,"r"),h=2097152;let g=0;for(;i<n&&!l;){const e=Buffer.alloc(h);let t=s.readSync(p,e,0,e.length,i);if(0===t)break;i+=t,u=Buffer.concat([u,e.subarray(0,t)]),o.parentPort.postMessage({type:5,progress:(100*i/n).toFixed(0)});const r=[];if(a(u,f,r),r.length>0){for(let e=0;e<r.length;e++)r[e]+=g;o.parentPort.postMessage({type:2,find_index:r})}g+=u.length-f.length,u=c(u,u.length-f.length,u.length)}o.parentPort.postMessage({type:3}),s.closeSync(p)}break;case 4:l=!0}}catch(e){console.log(e)}}))},896(e){e.exports=require("fs")}},t={};(function n(r){var o=t[r];if(void 0!==o)return o.exports;var s=t[r]={exports:{}};return e[r].call(s.exports,s,s.exports,n),s.exports})(285)})();