Selaa lähdekoodia

chore: Correct eslint errors in backend filesystem

Removes or disables the following eslint errors/warnings:

/puter/packages/backend/src/api/filesystem/FlagParam.js
  33:19  error  'APIError' is not defined  no-undef
  47:19  error  'APIError' is not defined  no-undef
  58:15  error  'APIError' is not defined  no-undef

/puter/packages/backend/src/api/filesystem/StringParam.js
  32:19  error  'APIError' is not defined  no-undef
  39:13  error  'APIError' is not defined  no-undef
  46:19  error  'APIError' is not defined  no-undef

/puter/packages/backend/src/filesystem/FilesystemService.js
  141:17  warning  Unexpected 'debugger' statement  no-debugger
  366:21  error    'services' is not defined        no-undef

/puter/packages/backend/src/filesystem/batch/BatchExecutor.js
  121:21  error  Do not assign to the exception parameter  no-ex-assign

/puter/packages/backend/src/filesystem/hl_operations/hl_data_read.js
  44:19  error  'APIError' is not defined     no-undef
  47:22  error  'chkperm' is not defined      no-undef
  48:19  error  'APIError' is not defined     no-undef
  51:29  error  'LLRead' is not defined       no-undef
  54:13  error  'version_id' is not defined   no-undef
  88:35  error  'PassThrough' is not defined  no-undef

/puter/packages/backend/src/filesystem/hl_operations/hl_mkdir.js
  68:49  error  'fs' is not defined  no-undef

/puter/packages/backend/src/filesystem/hl_operations/hl_move.js
  102:33  error  'get_user' is not defined  no-undef
  104:35  error  'get_user' is not defined  no-undef
  110:33  error  'df' is not defined        no-undef

/puter/packages/backend/src/filesystem/hl_operations/hl_read.js
  54:13  error  'stream' is constant  no-const-assign

/puter/packages/backend/src/filesystem/hl_operations/hl_stat.js
  40:37  error  'APIError' is not defined  no-undef

/puter/packages/backend/src/filesystem/lib/PuterPath.js
  67:5  error  Expected to return a value in getter 'hasRelativePortion'  getter-return

/puter/packages/backend/src/filesystem/ll_operations/ll_copy_idea.js
   53:21  error  'UploadProgressTracker' is not defined   no-undef
   73:17  error  'PuterS3StorageStrategy' is not defined  no-undef
  137:22  error  'LLFilesystemOperation' is not defined   no-undef

/puter/packages/backend/src/filesystem/ll_operations/ll_read.js
  102:65  error  'offset' is not defined  no-undef
  102:73  error  'offset' is not defined  no-undef
  102:80  error  'length' is not defined  no-undef

/puter/packages/backend/src/filesystem/ll_operations/ll_rmnode.js
  43:23  error  'APIError' is not defined  no-undef

/puter/packages/backend/src/filesystem/storage/SystemFSEntryService.js
  101:26  error  '_path' is not defined  no-undef

/puter/packages/backend/src/filesystem/validation.js
  27:29  error  Unexpected control character(s) in regular expression: \x00, \x1f  no-control-regex
  28:29  error  Unexpected control character(s) in regular expression: \x00, \x1f  no-control-regex
  28:31  error  Unnecessary escape character: \/                                   no-useless-escape
Sam Atkins 1 vuosi sitten
vanhempi
säilyke
8cf6379de3

+ 2 - 0
packages/backend/src/api/filesystem/FlagParam.js

@@ -16,6 +16,8 @@
  * You should have received a copy of the GNU Affero General Public License
  * along with this program.  If not, see <https://www.gnu.org/licenses/>.
  */
+const { APIError } = require('../../api/APIError');
+
 module.exports = class FlagParam {
     constructor (srckey, options) {
         this.srckey = srckey;

+ 2 - 0
packages/backend/src/api/filesystem/StringParam.js

@@ -16,6 +16,8 @@
  * You should have received a copy of the GNU Affero General Public License
  * along with this program.  If not, see <https://www.gnu.org/licenses/>.
  */
+const { APIError } = require('../../api/APIError');
+
 module.exports = class StringParam {
     constructor (srckey, options) {
         this.srckey = srckey;

+ 1 - 2
packages/backend/src/filesystem/FilesystemService.js

@@ -138,7 +138,6 @@ class FilesystemService extends AdvancedBase {
                 return permission.startsWith('fs:');
             },
             checker: async (actor, permission) => {
-                debugger;
                 if ( !(actor.type instanceof UserActorType) ) {
                     return undefined;
                 }
@@ -363,7 +362,7 @@ class FilesystemService extends AdvancedBase {
             [new_path, old_path.length + 1, old_path + '%', user_id]
         );
 
-        const log = services.get('log-service').create('update_child_paths');
+        const log = this.services.get('log-service').create('update_child_paths');
         log.info(`updated ${old_path} -> ${new_path}`);
 
         monitor.end();

+ 1 - 1
packages/backend/src/filesystem/batch/BatchExecutor.js

@@ -118,7 +118,7 @@ class BatchExecutor extends AdvancedBase {
                         alarm: true,
                     });
 
-                    e = APIError.adapt(e);
+                    e = APIError.adapt(e); // eslint-disable-line no-ex-assign
                 }
 
                 // Consume stream if there's a file

+ 5 - 0
packages/backend/src/filesystem/hl_operations/hl_data_read.js

@@ -18,6 +18,9 @@
  */
 const { stream_to_buffer } = require("../../util/streamutil");
 const { HLFilesystemOperation } = require("./definitions");
+const { chkperm } = require('../../helpers');
+const { LLRead } = require('../ll_operations/ll_read');
+const { APIError } = require('../../api/APIError');
 
 /**
  * HLDataRead reads a stream of objects from a file containing structured data.
@@ -38,6 +41,7 @@ class HLDataRead extends HLFilesystemOperation {
 
         const {
             fsNode,
+            version_id,
         } = this.values;
 
         if ( ! await fsNode.exists() ) {
@@ -85,6 +89,7 @@ class HLDataRead extends HLFilesystemOperation {
     }
 
     _stream_jsonl_lines_to_objects (stream) {
+        const { PassThrough } = this.modules.stream;
         const output_stream = new PassThrough();
         (async () => {
             for await (const line of stream) {

+ 1 - 0
packages/backend/src/filesystem/hl_operations/hl_mkdir.js

@@ -63,6 +63,7 @@ class MkTree extends HLFilesystemOperation {
 
     async _run () {
         const { values, context } = this;
+        const fs = context.get('services').get('filesystem');
 
         await this.create_branch_({
             parent_node: values.parent || await fs.node(new RootNodeSelector()),

+ 1 - 1
packages/backend/src/filesystem/hl_operations/hl_move.js

@@ -17,7 +17,7 @@
  * along with this program.  If not, see <https://www.gnu.org/licenses/>.
  */
 const APIError = require("../../api/APIError");
-const { chkperm, validate_fsentry_name, is_ancestor_of } = require("../../helpers");
+const { chkperm, validate_fsentry_name, is_ancestor_of, df, get_user } = require("../../helpers");
 const { LLMove } = require("../ll_operations/ll_move");
 const { RootNodeSelector } = require("../node/selectors");
 const { HLFilesystemOperation } = require("./definitions");

+ 1 - 1
packages/backend/src/filesystem/hl_operations/hl_read.js

@@ -41,7 +41,7 @@ class HLRead extends HLFilesystemOperation {
         }
 
         const ll_read = new LLRead();
-        const stream = await ll_read.run({
+        let stream = await ll_read.run({
             fsNode, actor,
             version_id,
             ...(byte_count !== undefined ? {

+ 1 - 0
packages/backend/src/filesystem/hl_operations/hl_stat.js

@@ -19,6 +19,7 @@
 const { chkperm } = require("../../helpers");
 const { Context } = require("../../util/context");
 const { HLFilesystemOperation } = require("./definitions");
+const { APIError } = require('../../api/APIError');
 
 class HLStat extends HLFilesystemOperation {
     static MODULES = {

+ 0 - 4
packages/backend/src/filesystem/lib/PuterPath.js

@@ -64,10 +64,6 @@ class PuterPath {
         return ! this.isAbsolute();
     }
 
-    get hasRelativePortion () {
-
-    }
-
     get reference () {
         if ( this.isAbsolute ) return this.constructor.NULL_UUID;
 

+ 1 - 0
packages/backend/src/filesystem/ll_operations/ll_copy_idea.js

@@ -30,6 +30,7 @@
     - easier to diagnose stuck operations
 
 */
+/* eslint-disable */
 
 const STEPS_COPY_CONTENTS = [
     {

+ 1 - 1
packages/backend/src/filesystem/ll_operations/ll_read.js

@@ -91,7 +91,7 @@ class LLRead extends LLFilesystemOperation {
                 const context = a.iget('context');
                 const svc_fileCache = context.get('services').get('file-cache');
 
-                const { fsNode } = a.values();
+                const { fsNode, offset, length } = a.values();
 
                 const maybe_buffer = await svc_fileCache.try_get(fsNode, a.log);
                 if ( maybe_buffer ) {

+ 1 - 0
packages/backend/src/filesystem/ll_operations/ll_rmnode.js

@@ -19,6 +19,7 @@
 const { Context } = require("../../util/context");
 const { ParallelTasks } = require("../../util/otelutil");
 const { LLFilesystemOperation } = require("./definitions");
+const { APIError } = require("../../api/APIError");
 
 class LLRmNode extends LLFilesystemOperation {
     async _run () {

+ 1 - 0
packages/backend/src/filesystem/storage/SystemFSEntryService.js

@@ -17,6 +17,7 @@
  * along with this program.  If not, see <https://www.gnu.org/licenses/>.
  */
 const { PuterPath } = require("../lib/PuterPath");
+const _path = require('path');
 
 // Redis keys:
 // <env>:<service>:<class>:<type>:<property>:<id>

+ 3 - 1
packages/backend/src/filesystem/validation.js

@@ -22,10 +22,12 @@ This module contains functions that validate filesystem operations.
 
 */
 
+/* eslint-disable no-control-regex */
+
 const config = require("../config");
 
 const path_excludes = () => /[\x00-\x1F]/g;
-const node_excludes = () => /[\/\x00-\x1F]/g;
+const node_excludes = () => /[/\x00-\x1F]/g;
 
 // this characters are not allowed in path names because
 // they might be used to trick the user into thinking