File processing method and device, equipment and storage medium
By setting up a virtual file system in the WebWorker at the browser front end, the target file and its associated files are processed automatically, which solves the problem of the coordination and consistency of the browser front end file system and improves rendering and interaction efficiency.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-12-04
- Publication Date
- 2026-04-03
Smart Images

Figure CN121786002A_ABST
Abstract
Description
Technical Field
[0001] This specification relates to the field of computer technology, and more specifically, to a file processing method, apparatus, device, and storage medium in the field of computer technology. Background Technology
[0002] As browser applications become increasingly complex, the amount of data that users interact with the browser frontend is growing dramatically. The frontend needs to process or store large amounts of binary or text data. Due to the browser's security architecture, the frontend cannot directly manipulate the local file system and can only perform unrelated file-level operations, which can easily lead to problems such as failed file maintenance and difficulties in file recycling. Summary of the Invention
[0003] This specification provides a file processing method, apparatus, device, and storage medium. The method provides integrated management of the file system in the browser front end, ensuring file interoperability and consistency.
[0004] Firstly, embodiments of this specification provide a file processing method, the method comprising: Receive file processing instructions sent by the front-end main thread; In the local storage space of the front end, determine the target file corresponding to the file processing instruction, and perform the first file processing on the target file based on the file processing instruction; Obtain the associated file corresponding to the target file, and perform second file processing on the associated file based on the first file processing.
[0005] Secondly, embodiments of this specification provide a document processing apparatus, which includes: The instruction receiving unit is used to receive file processing instructions sent by the front-end main thread. The first processing unit is used to determine the target file corresponding to the file processing instruction in the local storage space of the front end, and to perform first file processing on the target file based on the file processing instruction; The second processing unit is used to obtain the associated file corresponding to the target file and perform second file processing on the associated file based on the first file processing.
[0006] Thirdly, embodiments of this specification provide a computer device, the device including: a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the computer program, when executed by the processor, implements the steps of the method described above.
[0007] Fourthly, embodiments of this specification provide a storage medium storing a computer program, which, when executed by a processor, implements the steps of the method described above.
[0008] Fifthly, embodiments of this specification provide a computer program product, including: a computer program that, when executed by a processor of a computer device, enables the processor to at least implement the method as described in the first aspect.
[0009] In the embodiments of this specification, when a file processing instruction is received from the main thread of the browser frontend, the target file corresponding to the file processing instruction is determined in the local storage space of the frontend. Based on the file processing instruction, the target file undergoes first file processing to obtain the associated file corresponding to the target file. Based on the first file processing, the associated file undergoes second file processing. This embodiment of the specification applies to the background thread (WebWorker) of the frontend. A virtual file system is set up in the WebWorker. After processing the target file, the associated file corresponding to the target file is automatically processed. The file system is managed uniformly in the browser frontend, ensuring file collaboration and consistency. Attached Figure Description
[0010] To more clearly illustrate the technical solutions in the embodiments or prior art of this specification, the drawings used in the description of the embodiments or prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of this specification. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0011] Figure 1 This is a system architecture diagram of a file processing method provided in the embodiments of this specification; Figure 2 This is a flowchart illustrating a file processing method provided in an embodiment of this specification; Figure 3 This is a flowchart illustrating a file processing method provided in an embodiment of this specification; Figure 4 This is a flowchart illustrating a file processing method provided in an embodiment of this specification; Figure 5 This is a flowchart illustrating a file processing method provided in an embodiment of this specification; Figure 6 This is a flowchart illustrating a file processing method provided in an embodiment of this specification; Figure 7 This is a flowchart illustrating a file processing method provided in an embodiment of this specification; Figure 8 This is a flowchart illustrating a file processing method provided in an embodiment of this specification; Figure 9 This is a flowchart illustrating a file processing method provided in an embodiment of this specification; Figure 10 This is a flowchart illustrating a file processing method provided in an embodiment of this specification; Figure 11 This is a schematic diagram of the structure of a document processing device provided in the embodiments of this specification; Figure 12 This is a schematic diagram of the structure of a computer device provided in the embodiments of this specification. Detailed Implementation
[0012] The technical solutions in the embodiments of this specification will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this specification, and not all embodiments. Based on the embodiments in this specification, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this specification.
[0013] Please see Figure 1 , Figure 1 This is a system architecture diagram of a file processing method provided in the embodiments of this specification. For example... Figure 1 As shown in the embodiments of this specification, the file processing method provided is applicable to scenarios where file processing is performed in the browser frontend. A browser is a software application used to access, present, and interact with internet resources. It includes a frontend and a backend. The frontend includes a foreground main thread, WebWorkers, and local storage space, while the backend is the browser's remote server. The frontend sends transaction requests to the backend through interaction with the user. The backend receives the transaction requests sent by the frontend, performs data processing or file processing based on the transaction requests, and returns the processed data to the frontend for display.
[0014] The browser frontend performs UI rendering, user interaction, and data display functions through the main foreground thread. Since the main foreground thread is essentially single-threaded, WebWorkers are introduced to prevent thread blocking and data processing lag. WebWorkers are background threads within the frontend, running independent scripts outside the main foreground thread. By using multi-threaded parallel computing, they free the main foreground thread from time-consuming tasks, allowing it to focus on UI rendering and user interaction. However, as browser applications become increasingly complex, the amount of data interacting with the frontend has increased dramatically, leading to a surge in the amount of data the frontend needs to process and store. Due to browser security architecture limitations, WebWorkers adhere to the same-origin policy and user-triggered policies, meaning they can only process data triggered by the user through the main foreground thread and cannot actively access the local file system. This results in associated files not being automatically maintained or reclaimed.
[0015] To address the aforementioned issues, this specification provides a file processing method. Upon receiving a file processing instruction from the browser's front-end main thread, the method determines the target file corresponding to the instruction in the front-end's local storage space. Based on the instruction, it performs first file processing on the target file, obtains associated files corresponding to the target file, and then performs second file processing on the associated files based on the first file processing. This specification applies to a front-end WebWorker, where a virtual file system is set up. After processing the target file, the associated files corresponding to the target file are automatically processed. The browser front-end performs integrated management of the file system, ensuring file collaboration and consistency.
[0016] based on Figure 1 The system architecture diagram shown below will be used in conjunction with... Figures 2-10 This document provides a detailed description of the file processing methods provided in the embodiments of this specification.
[0017] Please see Figure 2 , Figure 2 This is a flowchart illustrating a file processing method provided in an embodiment of this specification. Figure 2 As shown, the method in the embodiments of this specification may include the following steps S102-S106.
[0018] S102 receives file processing instructions sent by the front-end main thread; Specifically, the embodiments in this specification apply to the WebWorker in the browser frontend. The WebWorker receives file processing instructions sent by the main thread of the frontend. File processing instructions include, but are not limited to, file write instructions, file append instructions, file delete instructions, directory read instructions, compression instructions, etc.
[0019] The file write command is used to write transaction data to a specified main file. Transaction data refers to the data processed by the user in the browser to complete a target transaction. The main file is used to store this transaction data. For example, if the target transaction is saving a document, the document saved by the user is the transaction data in the main file. The file append command is used to add new transaction data to the end of the main file. The file delete command is used to delete the specified main file from local storage space, thereby releasing storage space. Local storage space is used to persistently store data controlled and managed by the front-end code in the browser on the computer device. The directory read command is used to read file paths in local storage space. The file path is a string identifier that locates the file in local storage space. The compression command is used to compress the transaction data in the main file and the fragment files.
[0020] S104, determine the target file corresponding to the file processing instruction in the local storage space of the front end, and perform the first file processing on the target file based on the file processing instruction; Specifically, the file processing instruction carries the file path. Based on the file path, the system queries and locates the target file corresponding to the file processing instruction in the local storage space, and then performs the first file processing on the target file according to the file processing instruction. The target file is the file entity that the file processing instruction intends to operate on. Different file processing instructions correspond to different types of target files. File write instructions, file append instructions, and file delete instructions correspond to the main file, while directory read instructions correspond to all files in the local storage space. If the file processing instruction is to read a file from a directory, then different first file processing is performed for different types of target files.
[0021] S106, obtain the associated file corresponding to the target file, and perform second file processing on the associated file based on the first file processing.
[0022] Specifically, after WebWorker performs the first file processing on the target file, it automatically obtains the associated files corresponding to the target file and performs the second file processing on the associated files based on the first file processing. Since the target file and its corresponding associated files belong to the same user's associated file set, this embodiment of the specification, after performing the first file processing on target files belonging to the same associated file set, performs the second file processing on the associated files of the target file based on the first file processing, ensuring the automatic collaboration and consistency of multiple file types.
[0023] In the embodiments of this specification, when a file processing instruction is received from the main thread of the browser frontend, the target file corresponding to the file processing instruction is determined in the local storage space of the frontend. Based on the file processing instruction, the target file undergoes first file processing to obtain the associated file corresponding to the target file. Based on the first file processing, the associated file undergoes second file processing. This embodiment of the specification is applied to the WebWorker of the frontend. A virtual file system is set up in the WebWorker. After processing the target file, the associated file corresponding to the target file is automatically processed. The file system is managed in an integrated manner on the browser frontend, ensuring file collaboration and consistency.
[0024] Please see Figure 3 , Figure 3 This is a flowchart illustrating a file processing method provided in an embodiment of this specification. Figure 3 As shown, the method in the embodiments of this specification may include the following steps S202-S218.
[0025] S202, receives file processing instructions sent by the front-end main thread; Specifically, the embodiments in this specification apply to the WebWorker in the browser frontend. The WebWorker receives file processing instructions sent by the foreground main thread. The foreground main thread and the WebWorker communicate asynchronously through a message channel. The message channel is a cross-thread data transfer mechanism provided by the browser, supporting bidirectional data transfer between the foreground main thread and the WebWorker. Both parties send messages using the `postMessage` function and listen for and receive messages from each other using the `onmessage` function. Asynchronous communication refers to a communication mode where the WebWorker and the foreground main thread can execute subsequent tasks without waiting for a response from the other, thus avoiding impact on rendering and interaction in the main thread. File processing instructions include, but are not limited to, file write instructions, file append instructions, file delete instructions, directory read instructions, and compression instructions.
[0026] S204, If the file processing instruction is a file write instruction, then obtain the first main file path carried by the file write instruction; Specifically, in this embodiment, the file processing instruction is a file write instruction. After receiving the file write instruction sent by the foreground main thread, the WebWorker first obtains the first main file path carried by the file write instruction. The file write instruction is an instruction to write transaction data into the specified main file. The transaction data is the data that the user operates on in the browser to complete the target transaction, and the main file is used to store the transaction data. For example, when the target transaction is to save a document, the document saved by the user is the transaction data in the main file. The file path is a string identifier that locates the file position in the browser's local storage space. Since the file write instruction targets the main file, when it is determined that the file processing instruction is a file write instruction, the first main file path carried by the file write instruction is obtained.
[0027] S206, Create the first main file corresponding to the first main file path in the local storage space of the front end; Specifically, a first master file is created in the local storage space based on the first master file path. This first master file is the master file corresponding to the file write command. The local storage space is used to persistently store data controlled and managed by the front-end code in the browser on the computer device. Optionally, the local storage space can be a database, such as an indexed database (IndexedDB). IndexedDB supports storing large amounts of structured data (including binary data such as files) and provides an asynchronous transaction mechanism through indexes to ensure data consistency, meeting the core requirements of the virtual file system in the browser front-end for large-scale file data persistence, high-performance read and write, and complex state management.
[0028] S208, if the first user corresponding to the file write instruction is logged in, then write the first user identifier and the first transaction data carried by the file write instruction into the first main file; Specifically, after creating the first master file, the first transaction data carried in the file write instruction is written into the first master file. At the same time, it is checked whether the first user corresponding to the file write instruction is logged in. If the first user is logged in, the first user identifier is also written into the first master file to establish the association between the first master file and the first user.
[0029] For example, in the browser of an e-commerce system, the target transaction is logging. The first user, identified as A, is a staff member of the e-commerce system. The e-commerce system has logging enabled by default, recording the actions of the first user, A. When the first user is logged in, the main file path can be named from the user perspective, such as / logs / recordings / A.log; or from the session perspective, such as / logs / recordings / session_abc123.log, where session_abc123 is the session identifier generated by the system to record user A's actions on year a, month b, day c, with a session period of 24 hours. Assuming the first user, A, modifies the price of order B, the first transaction data includes the first user's identifier, the order identifier of order B, the price before modification, the price after modification, and the modification timestamp.
[0030] It should be noted that the information (including but not limited to user device information, user personal information, user behavior information, etc.) and data (including but not limited to data used for analysis, data stored, data displayed, etc.) involved in the embodiments of this specification are all authorized by the user or fully authorized by all parties, and the collection, use and processing of related data shall comply with the relevant laws, regulations and standards of the relevant countries and regions.
[0031] S210, determine the first metafile path of the first metadata file corresponding to the first master file and the first user file path of the first user file corresponding to the first master file based on the first master file path; Specifically, after determining the first master file, the associated files corresponding to the first master file are obtained, namely the first metadata file and the first user file. First, based on the master file path, the first metafile path of the first metadata file corresponding to the first master file, and the first user file path of the first user file corresponding to the first master file are determined. When the target file is the first master file, the associated files corresponding to the first master file are the first metadata file and the first user file. The master file, metadata file, and user file constitute a set of associated files corresponding to a user. The master file is used to store transaction data; the metadata file is used to store environment parameters for transaction data or to temporarily store transaction requests; the user file is a user-state information file, bound to the user's login information, and used to store the user's authentication information. The file paths in the embodiments of this specification are based on a systematic naming convention. Optionally, the metafile path has a fixed suffix "meta," and the user file path has a fixed suffix "usr_user_Id." Here, `user_Id` represents the user identifier. Assuming `user_Id` is A, and the first main file path is ` / logs / recordings / A.log`, then the first meta file path could be ` / logs / recordings / A.log_meta`, and the first user file path could be ` / logs / recordings / A.log_usr_A`. Similarly, assuming the first main file path is ` / logs / recordings / session_abc123.log`, then the first meta file path could be ` / logs / recordings / session_abc123.log_meta`, and the first user file path could be ` / logs / recordings / session_abc123.log_usr_A`.
[0032] S212, create the first metadata file corresponding to the first metadata file path in the local storage space, and create the first user file corresponding to the first user file path in the local storage space; S214, If the first user is logged in, then obtain the first user's first authentication information from the login status; S216, Write the environment parameters corresponding to the first transaction data into the first metadata file, and write the first user identifier and the first authentication information into the first user file; Specifically, a first metadata file corresponding to the first metafile path and a first user file corresponding to the first user file path are created in the local storage space. When the first user is logged in, the first authentication information of the first user is obtained from the login status of the first user. The first authentication information and the first user_Id are written into the first user file, and the environment parameters corresponding to the first transaction data are written into the first metadata file.
[0033] Metadata files store environmental parameters related to transaction data. These parameters provide an interpretive framework for the transaction data, including: the system, device, and / or user from which the transaction data originates; the time, location, and / or network status where the transaction data was generated; the encoding format, encryption method, and / or compression algorithm of the transaction data; and the system and / or transaction scenario in which the transaction data is used. Authentication information refers to the user's identity authentication information, including login credentials such as username, password, and temporary token. The token is a temporary credential used to verify the user's identity and authorization. It can be generated by the server and returned to the user upon their first login, allowing the user to prove their identity or obtain permissions in subsequent operations.
[0034] S218, obtain the first transaction request corresponding to the first transaction data, and send the first transaction request, the first transaction data, and the first authentication information to the browser's server, so that the server can perform transaction operations on the first transaction data based on the first transaction request after verifying the first authentication information.
[0035] Specifically, when the first user is logged in, the system directly retrieves the first transaction request corresponding to the first transaction data and sends the first transaction request, the first transaction data, and the first authentication information to the browser's server. This allows the server to verify the first authentication information and, after confirming that the first user has permission to make the first transaction request, to perform transaction operations on the first transaction data based on the first transaction request. The transaction request is a request parameter sent by the user to the server through the browser frontend, used to instruct the server to operate on the transaction data and complete the target transaction.
[0036] For example, taking the example in step S208, suppose the target transaction is recording a log. During the log recording process, the first user A modifies the price of order B. If the price before modification was 110 and the price after modification is 100, then the first transaction request corresponding to the first transaction data is to modify the price. After receiving the first transaction request, the server modifies the price of order B from 110 to 100 based on the order identifier of order B, the price before modification, and the price after modification in the first transaction data.
[0037] In one feasible implementation, not all transaction data corresponds to a transaction request that needs to be sent to the server. If no first transaction request corresponding to the first transaction data is obtained, then it is not necessary to send the first transaction request, the first transaction data, and the first authentication information to the browser's server. For example, if user A enters the product details page at 17:00, this behavior only needs to be recorded in the main file for analyzing user A's behavior or troubleshooting. Since the server does not need to change the data state, the transaction request cannot be obtained.
[0038] It should be noted that the WebWorker in the embodiments of this specification follows a transaction wrapping mechanism when processing files to ensure that the file processing operation is executed successfully. If an exception occurs during the execution process, it will roll back to before the file processing and re-execute the file processing to prevent data anomalies.
[0039] In the embodiments of this specification, WebWorker receives a file write command sent by the foreground main thread and creates a main file in the local storage space according to the main file path carried in the file write command. When the user is logged in, the user identifier and transaction data are written to the main file. At the same time, the meta file path and user file path are determined according to the main file path, and then the metadata file and user file are created. The user's authentication information and user identifier are written to the user file, and the environment parameters corresponding to the transaction data are written to the metadata file. When there is a corresponding transaction request for the transaction data, the transaction request is obtained, and the transaction request, transaction data, and authentication information are sent to the browser's server. This allows the server to perform transaction operations on the transaction data based on the transaction request after verifying the user's authentication information. The WebWorker provided in the embodiments of this specification automatically creates the user file and metadata file corresponding to the main file when writing files, avoiding the situation where the main file exists but the corresponding user file and metadata file are missing. This constructs a virtual file system for integrated management, ensuring file collaboration and consistency. In addition, the creation of the file system is all performed in WebWorker, without relying on the foreground main thread, further preventing the foreground main thread from being blocked and improving the rendering and interaction efficiency of the foreground main thread.
[0040] Please see Figure 4 , Figure 4 This is a flowchart illustrating a file processing method provided in an embodiment of this specification. Figure 4 As shown, the method in the embodiments of this specification may include the following steps S302-S322.
[0041] S302 receives file processing instructions sent by the front-end main thread; Please refer to step S202 for the specific process, which will not be repeated here.
[0042] S304, If the file processing instruction is a file write instruction, then obtain the first main file path carried by the file write instruction; Please refer to step S204 for the specific process, which will not be repeated here.
[0043] S306, Create the first main file corresponding to the first main file path in the local storage space of the front end; Please refer to step S206 for the specific process, which will not be repeated here.
[0044] S308, if the first user corresponding to the file write instruction is not logged in, then the first transaction data carried by the file write instruction is written to the first main file; Specifically, if the first user is not logged in, the first transaction data is written to the first main file. Then, the system continuously checks whether the first user is logged in. When the system detects that the first user is logged in, the user's identifier is written to the first main file.
[0045] For example, in the browser of an e-commerce system, the target transaction is logging. If the first user is not logged in, then the first user is identified as an anonymous user. When the anonymous user operates in the e-commerce system, the system automatically enables logging to record the anonymous user's actions. When the anonymous user is not logged in, the main file path can be named from the session perspective, for example, ` / logs / recordings / session_abc123.log`, where `session_abc123` is the session identifier generated by the system to record the anonymous user's actions on date `a`, `b`, and `c`, with a session period of 24 hours. Assuming the anonymous user modifies the price of order B, the first transaction data includes the order identifier of order B, the price before modification, the price after modification, and the modification timestamp. Since the anonymous user is not logged in, the user identifier is missing, and therefore the transaction data does not contain the user identifier.
[0046] S310, determine the first metafile path of the first metadata file corresponding to the first master file and the first user file path of the first user file corresponding to the first master file based on the first master file path; Specifically, after determining the first master file, the associated files corresponding to the first master file are obtained, namely the first metadata file and the first user file. First, based on the master file path, the first metafile path of the first metadata file corresponding to the first master file, and the first user file path of the first user file corresponding to the first master file are determined. When the target file is the first master file, the associated files corresponding to the first master file are the first metadata file and the first user file. The master file, metadata file, and user file constitute a set of associated files corresponding to a user. The master file is used to store transaction data; the metadata file is used to store environment parameters for transaction data or to temporarily store transaction requests; the user file is a user-state information file, bound to the user's login information, and used to store the user's authentication information. The file paths in the embodiments of this specification are based on a systematic naming convention. Optionally, the metafile path has a fixed suffix "meta," and the user file path has a fixed suffix "usr_user_Id." Here, user_Id is the user identifier. Since the first user is currently not logged in, the first user identifier cannot be known. Therefore, a temporary identifier can be assigned to the first user. After the first user logs in later, the temporary identifier will be replaced with the first user identifier. Assuming the temporary identifier is C, the first main file path is / logs / recordings / session_abc123.log, then the first meta file path can be / logs / recordings / session_abc123.log_meta, and the first user file path can be / logs / recordings / session_abc123.log_usr_C.
[0047] S312, create the first metadata file corresponding to the first metadata file path in the local storage space, and create the first user file corresponding to the first user file path in the local storage space; In one feasible implementation, when the first user is not logged in, the user_Id is unknown. Therefore, the path of the first metadata file corresponding to the first metadata file of the first main file can be determined based on the main file path, and the first metadata file corresponding to the first metadata file path can be created in local storage. Subsequently, the system continuously checks whether the first user is logged in. When the first user is detected to be logged in, the first user's identifier is obtained. Based on the first user identifier and the first main file path, the path of the first user file corresponding to the first user file of the first main file is determined, and the first user file corresponding to the first user file path is created in local storage.
[0048] S314, If the first user is not logged in, then obtain the first transaction request corresponding to the first transaction data; S316, Write the environment parameters corresponding to the first transaction data and the first transaction request into the first metadata file; Specifically, even if the first user is not logged in, the first transaction data can still include the first transaction request, and the first transaction request corresponding to the first transaction data is obtained. The environment parameters and the first transaction request corresponding to the first transaction data are written into the first metadata file. The metadata file stores environment parameters related to the transaction data, providing an interpretive framework for the transaction data, including: the system, device, and / or user from which the transaction data originates; the time, location, and / or network status where the transaction data was generated; the encoding format, encryption method, and / or compression algorithm of the transaction data; and the system and / or transaction scenario for which the transaction data is used. The transaction request is the request parameter sent by the user to the server through the browser frontend, used to enable the server to operate on the transaction data and complete the target transaction. When the user is not logged in, the frontend cannot know who the user is. To ensure data security, the first transaction request is temporarily stored in the metadata file, so that the transaction request and associated user identity information can be automatically resent to the server after the user logs in.
[0049] In one feasible implementation, not all transaction data corresponds to a transaction request that needs to be sent to the server. If no first transaction request corresponding to the first transaction data is obtained, there is no need to temporarily store the first transaction request in the first metadata file. For example, if the first user enters the product details page at 17:00, this behavior only needs to be recorded in the main file for analyzing the first user's behavior or troubleshooting. Since the transaction data does not require the server to change the data state, the transaction request cannot be obtained.
[0050] S318, when the first user is detected to be logged in, obtain the first user identifier and first authentication information of the first user; Specifically, the system continuously monitors whether the first user is logged in. When the first user is detected to be logged in, the system obtains the first user's identifier and authentication information. The authentication information is the user's identity authentication information, which includes the user's login credentials, such as username, password, and temporary token. The token is a temporary credential for verifying the user's identity and authorization. It can be generated by the server and returned to the user upon the user's first login, allowing the user to prove their identity or obtain permissions in subsequent operations.
[0051] It should be noted that the information (including but not limited to user device information, user personal information, user behavior information, etc.) and data (including but not limited to data used for analysis, data stored, data displayed, etc.) involved in the embodiments of this specification are all authorized by the user or fully authorized by all parties, and the collection, use and processing of related data shall comply with the relevant laws, regulations and standards of the relevant countries and regions.
[0052] S320, write the first user identifier and the first authentication information into the first user file; Specifically, the first user identifier and the first authentication information are written into the first user file, and the temporary identifier in the first user file path is replaced with the first user identifier.
[0053] For example, suppose the temporary identifier is C, and the initially determined first user file path is / logs / recordings / session_abc123.log_usr_C. When the first user logs in, it is known that the first user identifier is A, then the first user file path is / logs / recordings / session_abc123.log_usr_A.
[0054] S322, send a first transaction request, first transaction data and first authentication information to the browser's server, so that the server can perform transaction operations on the first transaction data based on the first transaction request after verifying the first authentication information.
[0055] Specifically, once the first user identifier is known, if the first transaction request is temporarily stored in the first metadata file, the correspondence between the first transaction request and the first user identifier is determined, and the first transaction request, first transaction data, and first authentication information are sent to the browser's server so that the server can verify the first authentication information. After determining that the first user has the authority to make the first transaction request, the server performs transaction operations on the first transaction data based on the first transaction request.
[0056] For example, taking the example in step S308, after the first user logs in, it is known that the first user's first user identifier is A. The first transaction data is associated with the first user identifier, and it is found that during the log recording process, the first user A modified the price of order B. If the price before modification was 110 and the price after modification is 100, then the first transaction request corresponding to the first transaction data is to modify the price. After receiving the first transaction request, the server modifies the price of order B from 110 to 100 according to the order identifier of order B, the price before modification, and the price after modification in the first transaction data.
[0057] It should be noted that the WebWorker in the embodiments of this specification follows a transaction wrapping mechanism when processing files to ensure that the file processing operation is executed successfully. If an exception occurs during the execution process, it will roll back to before the file processing and re-execute the file processing to prevent data anomalies.
[0058] In the embodiments of this specification, WebWorker receives a file write command sent by the foreground main thread and creates a main file in the local storage space according to the main file path carried in the file write command. When the user is not logged in, transaction data is written to the main file, and the metadata file path and user file path are determined according to the main file path, thereby creating a metadata file and a user file. The environment parameters corresponding to the transaction data are written to the metadata file. When there is a corresponding transaction request for the transaction data, the transaction request is obtained and temporarily stored in the metadata file. The system continuously checks whether the user is logged in. When the user is logged in, the user identifier and authentication information are obtained and written to the user file to complete the user file. The transaction request and user identifier are associated, and the transaction request, transaction data, and authentication information are sent to the server so that the server can perform transaction operations on the transaction data based on the transaction request after verifying the authentication information. The WebWorker provided in the embodiments of this specification automatically creates a user file and metadata file corresponding to the main file when writing files, avoiding the situation where the main file exists but the corresponding user file and metadata file are missing, thereby constructing a virtual file system for integrated management. When a user is not logged in, their transaction requests are temporarily stored in a metadata file. This allows for subsequent logins by associating the user's identifier with the transaction request, retrieving the user's authentication information, and resending the transaction request, authentication information, and transaction data for timely processing. Furthermore, file system creation is performed entirely within WebWorkers, eliminating the need for the foreground main thread and further preventing foreground main thread blocking, thus improving rendering and interaction efficiency.
[0059] Please see Figure 5 , Figure 5 This is a flowchart illustrating a file processing method provided in an embodiment of this specification. Figure 5 As shown, the method in the embodiments of this specification may include the following steps S402-S414.
[0060] S402 receives file processing instructions sent by the front-end main thread; Please refer to step S302 for the specific process, which will not be repeated here.
[0061] S404, if the file processing instruction is a file append instruction, then obtain the second main file path carried by the file append instruction; Specifically, in this embodiment, the file processing instruction is a file append instruction. After receiving the file append instruction sent by the foreground main thread, the WebWorker first obtains the second main file path carried by the file append instruction. The file append instruction is an instruction to add new transaction data to the end of the main file. The file path is a string identifier that locates the file position in the browser's local storage space. Since the file append instruction targets the main file, when it is determined that the file processing instruction is a file append instruction, the second main file path carried by the file append instruction is obtained.
[0062] S406, determine the second main file corresponding to the second main file path in the local storage space of the front end; Specifically, the second main file corresponding to the second main file path is determined in the local storage space of the front end. The local storage space is used to persistently store data controlled and managed by the front end code in the browser on the computer device. Optionally, the local storage space can be a database, such as IndexedDB. IndexedDB supports storing large amounts of structured data (including binary data such as files) and provides an asynchronous transaction mechanism through indexes to ensure data consistency, which meets the core requirements of the virtual file system in the browser front end for large-scale file data persistence, high-performance read and write, and complex management of state.
[0063] S408, write the second transaction data carried by the file append instruction into the second main file; Specifically, the system retrieves the second transaction data carried by the file append command and writes it to the end of the second main file. Transaction data refers to the data processed by the user in the browser to complete the target transaction, and the main file is used to store this transaction data.
[0064] For example, in the browser of an e-commerce system, the target transaction is to record user D's logs, and the lifecycle of this transaction is one week. Within this week, if user D performs an operation in the browser for the first time, a second main file is created, and the transaction data of user D's first operation is written into the second main file. All subsequent operations on the transaction data must send a file append instruction to the WebWorker through the foreground main thread, and the transaction data of subsequent operations are written to the end of the second main file in chronological order.
[0065] It should be noted that the information (including but not limited to user device information, user personal information, user behavior information, etc.) and data (including but not limited to data used for analysis, data stored, data displayed, etc.) involved in the embodiments of this specification are all authorized by the user or fully authorized by all parties, and the collection, use and processing of related data shall comply with the relevant laws, regulations and standards of the relevant countries and regions.
[0066] S410, when writing the second transaction data, obtain the number of bytes in the second main file; S412, if the number of bytes reaches the preset byte threshold, then determine the first fragment file path of the first fragment file corresponding to the second main file based on the second main file path; Specifically, while writing the second transaction data, the number of bytes in the second main file is obtained and compared with a preset byte threshold. If the number of bytes reaches the preset byte threshold, a first shard file corresponding to the second main file is created, and the first shard file is determined as the associated file of the second main file. First, the path of the first shard file is determined based on the path of the second main file. The preset byte threshold is the maximum number of bytes in both the main file and the shard file. This preset byte threshold is set to prevent excessively large single files from affecting read / write performance and to improve the efficiency of concurrent file processing. Therefore, for very large files, WebWorker automatically splits them. Optionally, the suffix of the chunk file path can be chunk_N. Assuming the path of the second main file is / logs / recordings / session_abc123.log, then the path of the first chunk file of the first chunk file obtained by the first chunking of the second main file can be / logs / recordings / session_abc123.log_chunk_1, and the path of the first chunk file of the first chunk file obtained by the second chunking of the second main file can be / logs / recordings / session_abc123.log_chunk_2.
[0067] It should be noted that when creating the main file and writing transaction data to the main file for the first time, it is also necessary to obtain the number of bytes in the main file. When the number of bytes in the main file reaches the preset byte threshold, a fragment file of the main file is created to prevent the main file from exceeding the limit due to writing too much transaction data for the first time.
[0068] S414, create the first fragment file corresponding to the first fragment file path in the local storage space, and write the remaining transaction data in the second transaction data that has not been written to the second main file into the first fragment file.
[0069] Specifically, a first shard file is created in the local storage space based on the first shard file path. The remaining transaction data from the second transaction data that has not yet been written to the second main file is then written to the first shard file. After the first shard file is created, it is treated the same as the user file and metadata file, and is referred to as the associated file of the second main file.
[0070] It should be noted that the WebWorker in the embodiments of this specification follows a transaction wrapping mechanism when processing files to ensure that the file processing operation is executed successfully. If an exception occurs during the execution process, it will roll back to before the file processing and re-execute the file processing to prevent data anomalies.
[0071] In the embodiments described in this specification, the WebWorker receives a file append instruction sent by the foreground main thread, writes transaction data into the main file, and when the number of bytes in the main file reaches a preset byte threshold, it creates a split file for the main file to prevent a single file from being too large and affecting read and write performance, thus improving the efficiency of concurrent file processing. Furthermore, splitting the main file within the WebWorker does not rely on the foreground main thread, further preventing foreground main thread blocking and improving the rendering and interaction efficiency of the foreground main thread.
[0072] Please see Figure 6 , Figure 6 This is a flowchart illustrating a file processing method provided in an embodiment of this specification. Figure 6 As shown, the method in the embodiments of this specification may include the following steps S502-S510.
[0073] S502 receives file processing instructions sent by the front-end main thread; Please refer to step S402 for the specific process, which will not be repeated here.
[0074] S504, if the file processing instruction is a file deletion instruction, then obtain the third main file path carried by the file deletion instruction; Specifically, in this embodiment, the file processing instruction is a file deletion instruction. After receiving the file deletion instruction sent by the foreground main thread, the WebWorker first obtains the third main file path carried by the file deletion instruction. The file deletion instruction is an instruction to delete the specified main file in the local storage space, thereby releasing the storage space. The file path is a string identifier that locates the file position in the browser's local storage space. Since the file deletion instruction targets the main file, when it is determined that the file processing instruction is a file deletion instruction, the third main file path carried by the file deletion instruction is obtained.
[0075] S506, delete the third main file corresponding to the third main file path in the local storage space of the front end; Optionally, the third main file corresponding to the path of the third main file can be determined in the local storage space of the front end, and then the third main file can be deleted. The local storage space is used to persistently store data controlled and managed by the front end code in the browser on the computer device. Optionally, the local storage space can be a database, such as IndexedDB. IndexedDB supports storing large amounts of structured data (including binary data such as files) and provides an asynchronous transaction mechanism through indexes to ensure data consistency, meeting the core requirements of the virtual file system in the browser front end for large-scale file data persistence, high-performance read and write, and complex management of state.
[0076] S508, determine the second metadata file and the second user file corresponding to the third master file in the local storage space; S510, delete the second metadata file and the second user file.
[0077] Specifically, in this embodiment of the specification, after deleting the main file in the local storage space, it is necessary to also delete the auxiliary files of the main file. The associated files of the third main file are the second metadata file and the second user file. Based on the path of the third main file, the file path of the second metadata file and the file path of the second user file corresponding to the third main file are determined. Then, the second metadata file and the second user file are determined in the local storage space, and the second metadata file and the second user file are deleted from the local storage space.
[0078] It should be noted that if a third master file has a corresponding fragment file, then that fragment file is also an associated file of the third master file, and the fragment file corresponding to the third master file is deleted from the local storage space.
[0079] It should be noted that the WebWorker in the embodiments of this specification follows a transaction wrapping mechanism when processing files to ensure that the file processing operation is executed successfully. If an exception occurs during the execution process, it will roll back to before the file processing and re-execute the file processing to prevent data anomalies.
[0080] In the embodiments described in this specification, the WebWorker receives a file deletion command sent by the foreground main thread, performs a deletion operation on the main file, and automatically deletes the corresponding auxiliary files, freeing up storage space and preventing data redundancy in local storage space. Furthermore, automatically deleting auxiliary files within the WebWorker does not rely on the foreground main thread, further preventing foreground main thread blocking and improving its rendering and interaction efficiency.
[0081] Please see Figure 7 , Figure 7 This is a flowchart illustrating a file processing method provided in an embodiment of this specification. Figure 7As shown, the method in the embodiments of this specification may include the following steps S602-S618.
[0082] S602 receives file processing instructions sent by the front-end main thread; Please refer to step S502 for the specific process, which will not be repeated here.
[0083] S604, if the file processing instruction is a directory read instruction, then the file path in the local storage space of the front end is read based on the directory read instruction; Specifically, in this embodiment, the file processing instruction is a directory read instruction. After receiving the directory read instruction sent by the foreground main thread, the WebWorker determines that the directory read instruction targets all file paths in the local storage space of the front end. Based on the directory read instruction, it reads all file paths in the local storage space, with the target files being all files in the local storage space. The directory read instruction is an instruction to read file paths in the local storage space, where a file path is a string identifier used to locate the file position in the local storage space. The local storage space is used to persistently store data controlled and managed by the front-end code in the browser on the computer device. Optionally, the local storage space can be a database, such as IndexedDB. IndexedDB supports storing large amounts of structured data (including binary data such as files) and provides an asynchronous transaction mechanism through indexes to ensure data consistency, meeting the core requirements of the virtual file system in the browser front end for large-scale file data persistence, high-performance read / write, and complex management states.
[0084] S606, determine the file type of the target file corresponding to the file path based on the file path; Specifically, the file type of the target file corresponding to the file path is determined based on the file path. File types include main file types and auxiliary file types. Auxiliary file types include user file types, metadata file types, and fragment file types. The main file is the core file storing transaction data, which is the data generated by the user in the browser to complete the target transaction. The metadata file stores environment parameters for the transaction data or temporarily stores transaction requests. The user file is a user-state information file, bound to the user's login information, used to store the user's authentication information. Fragment files are created when the main file's byte count reaches a preset byte threshold to store transaction data. The main file and auxiliary files are corresponding associated files.
[0085] In the embodiments of this specification, the file path format is set based on preset rules, and the suffix of the main file is set according to the transaction type. For example, the main file suffix in a log transaction is .log, and the main file suffix in a cache transaction is .tmp. The metadata file corresponding to the main file has the suffix "meta", the user file has the suffix "usr_user_Id", and the chunk file has the suffix "chunk_N". Therefore, the file type of each target file can be determined based on the suffix of each file path.
[0086] S608, if the file type indicates that the target file is the fourth main file, then obtain the third user file corresponding to the fourth main file, and obtain the user information contained in the third user file; Specifically, if the target file's file type is a primary file, then the target file is the fourth primary file, and the associated file of the fourth primary file is the corresponding third user file. The third user file corresponding to the fourth primary file is obtained, and the user information contained within it is retrieved. A completeness check is performed on the user information in the third user file to determine if any information is missing. The user information includes user identifiers and authentication information. Authentication information refers to the user's identity authentication information, which includes the user's login credentials, such as username, password, and temporary token. The token is a temporary credential for verifying user identity and authorization. It can be generated by the server and returned to the user upon their first login, allowing the user to prove their identity or obtain permissions in subsequent operations.
[0087] In one feasible implementation, if the third user file does not exist in the local storage space, then the third user file is created.
[0088] S610, if there is missing information in the user information, when the second user corresponding to the third user file is logged in, the second user identifier and / or second authentication information of the second user are obtained, and the missing information is supplemented based on the second user identifier and / or second authentication information; Specifically, if there is missing information in the user information, the system checks whether the second user corresponding to the third user file is logged in. If the second user is detected to be logged in, the system retrieves the second user's second user identifier and / or second authentication information from the second user's login information based on the missing information, and supplements the missing information based on the second user identifier and / or second authentication information. If the missing information is a user identifier, the user identifier is written to the user file; if the missing information is authentication information, the authentication information is written to the user file.
[0089] S612, retrieve the third metadata file corresponding to the fourth master file, and retrieve the third transaction data in the fourth master file; Specifically, after completing the user information in the third user file, the third metadata file corresponding to the fourth master file is obtained, along with the third transaction data in the fourth master file. This is used to check whether the third metadata file stores a second transaction request corresponding to the third transaction data. The transaction request is a request parameter sent by the user to the server through the browser frontend, used to enable the server to operate on the transaction data and complete the target transaction.
[0090] In one feasible implementation, if the third metadata file does not exist in the local storage space, a third metadata file is created to supplement the missing information in the third metadata file.
[0091] S614, If a second transaction request corresponding to the third transaction data exists in the third metadata file, then obtain the second transaction request; Specifically, if a second transaction request corresponding to the third transaction data exists in the third metadata file, then the second transaction request is retrieved. When user information is missing, the transaction request is temporarily stored in the metadata file until the user information is complete. Then, the transaction request in the metadata file is retrieved, and the correspondence between the user information and the transaction request is established.
[0092] S616, send a second transaction request, third transaction data and second authentication information to the browser's server, so that the server can perform transaction operations on the third transaction data based on the second transaction request after verifying the second authentication information; Specifically, the system sends a second transaction request, third transaction data, and second authentication information to the server so that the server can verify the second authentication information and determine that the second user has the authority to make the second transaction request. Then, the system performs transaction operations on the third transaction data based on the second transaction request.
[0093] S618, send the path of the fourth main file to the foreground main thread.
[0094] Specifically, the path to the fourth main file is sent to the foreground main thread. The purpose of the directory read instruction is to return the path to the main file of the correctly positioned main file in the local storage space to the foreground main thread, hiding all auxiliary files in the local storage space, and ensuring that the foreground main thread does not need to be aware of or intervene in any operations on the auxiliary files. A correctly positioned main file means that each main file has a corresponding user file and metadata file, and that the information in the user file and metadata file is complete. In this embodiment, the auxiliary files of the main file are automatically completed before the main file path is returned. If the auxiliary files of the main file cannot be completed, there is no need to return the path to the main file of that main file to the foreground main thread.
[0095] It should be noted that the WebWorker in the embodiments of this specification follows a transaction wrapping mechanism when processing files to ensure that the file processing operation is executed successfully. If an exception occurs during the execution process, it will roll back to before the file processing and re-execute the file processing to prevent data anomalies.
[0096] In the embodiments described in this specification, WebWorker receives a directory read instruction sent by the foreground main thread, scans all file paths in the local storage space to determine the file type of each target file, and performs file processing operations on the associated files of each target file according to the file type of each target file. When the target file is a main file, after completing the information in the user file of the main file, a transaction request is sent to the server in conjunction with the transaction request in the metadata file, and finally the main file path of the main file is returned to the foreground main thread. Automatically completing the user information in the user file of the main file according to the target read instruction and sending the transaction request in the metadata file prevents data loss, enhances the robustness of the file system, and ensures the data integrity and consistency of the file system.
[0097] Please see Figure 8 , Figure 8 This is a flowchart illustrating a file processing method provided in an embodiment of this specification. Figure 8 As shown, the method in the embodiments of this specification may include the following steps S702-S710.
[0098] S702 receives file processing instructions sent by the front-end main thread; Please refer to step S602 for the specific process, which will not be repeated here.
[0099] S704, if the file processing instruction is a directory read instruction, then the file path in the local storage space of the front end is read based on the directory read instruction; Please refer to step S604 for the specific process, which will not be repeated here.
[0100] S706, determine the file type of the target file corresponding to the file path based on the file path; Please refer to step S606 for the specific process, which will not be repeated here.
[0101] S708, if the file type indicates that the target file is an auxiliary file, then query the fifth main file corresponding to the auxiliary file in the local storage space; S710: If the fifth main file is not found, the auxiliary file will be deleted.
[0102] Specifically, if the target file is an auxiliary file, then the target file is an auxiliary file. For any auxiliary file in the local storage space, its corresponding fifth master file is queried; the fifth master file is the associated file. The master file is the core file. If an auxiliary file does not have a corresponding master file, the data in the auxiliary file becomes meaningless, forming data silos. Therefore, if no fifth master file is found, the auxiliary file is deleted.
[0103] It should be noted that the WebWorker in the embodiments of this specification follows a transaction wrapping mechanism when processing files to ensure that the file processing operation is executed successfully. If an exception occurs during the execution process, it will roll back to before the file processing and re-execute the file processing to prevent data anomalies.
[0104] In the embodiments described in this specification, WebWorker receives a directory read command sent by the foreground main thread, scans all file paths in the local storage space to determine the file type of each target file, and performs file processing operations on the associated files of each target file according to the file type of each target file. When the target file is an auxiliary file, it checks whether the auxiliary file has a corresponding main file. If no corresponding main file is found for the auxiliary file, the auxiliary file is deleted to prevent data silos and ensure the data integrity of the file system.
[0105] Please see Figure 9 , Figure 9 This is a flowchart illustrating a file processing method provided in an embodiment of this specification. Figure 9 As shown, the method in the embodiments of this specification may include the following steps S802-S812.
[0106] S802 receives file processing instructions sent by the front-end main thread; Please refer to step S702 for the specific process, which will not be repeated here.
[0107] S804, if the file processing instruction is a compression instruction, then obtain the path of the sixth main file carried by the compression instruction; Specifically, in this embodiment, the file processing instruction is a compression instruction. After receiving the compression instruction sent by the foreground main thread, the WebWorker first obtains the sixth main file path carried by the compression instruction. The compression instruction is an instruction to compress transaction data in the main file and the fragmented files. Transaction data is the data that the user operates on in the browser to complete the target transaction. The main file is used to store transaction data, and the fragmented files are files created after the number of bytes in the main file reaches a preset byte threshold to store transaction data. The file path is a string identifier that locates the file position in the browser's local storage space. Since the compression instruction targets both the main file and the fragmented files, when it is determined that the file processing instruction is a compression instruction, the sixth main file path carried by the compression instruction is obtained.
[0108] S806, determine the sixth main file corresponding to the sixth main file path in the local storage space of the front end; Specifically, the sixth main file corresponding to the sixth main file path is determined in the local storage space of the front end. The local storage space is used to persistently store data controlled and managed by the front end code in the browser on the computer device. Optionally, the local storage space can be a database, such as an indexed database (IndexedDB). IndexedDB supports storing large amounts of structured data (including binary data such as files) and provides an asynchronous transaction mechanism through indexes to ensure data consistency, which meets the core requirements of the virtual file system in the browser front end for large-scale file data persistence, high-performance read and write, and complex management of state.
[0109] S808, retrieve the fourth transaction data in the sixth master file, retrieve the second fragment file corresponding to the sixth master file, and retrieve the fifth transaction data in the second fragment file; Specifically, the compression command compresses transaction data in the main file and the fragment files. After determining the sixth main file, the fourth transaction data in the sixth main file is retrieved. The second fragment file corresponding to the sixth main file is then queried in the local storage space. If the second fragment file is found, it is retrieved, and the fifth transaction data in the second fragment file is obtained. It should be noted that if the second fragment file is found, it must be at least one file.
[0110] In one feasible implementation, if the second fragment file is not found in the local storage space, there is no need to obtain the second fragment file and the fifth transaction data in the second fragment file; only the fourth transaction data is compressed.
[0111] S810 concatenates the fourth and fifth transaction data in the local storage space to obtain the sixth transaction data; Specifically, the fourth and fifth transaction data are concatenated in local storage to obtain the sixth transaction data. Since transaction data is appended to the end of the main file, if the number of bytes in the main file reaches a preset byte threshold, a fragment file is created, and transaction data is written to the fragment file. This process continues until the number of bytes in the fragment file also reaches the preset byte threshold, at which point a new fragment file is created. Therefore, when concatenating transaction data, it is done in the order in which the transaction data was written to prevent data corruption.
[0112] S812 compresses the sixth transaction data and encapsulates the compressed sixth transaction data in the compressed file corresponding to the sixth main file.
[0113] Specifically, the sixth transaction data is compressed using a compression algorithm. The compressed sixth transaction data is then encapsulated in a compressed file as a Binary Large Object (Blob). Blobs are used to store data types or objects containing large amounts of binary data. The compressed file is also stored in local storage space. To free up local storage space, the sixth main file and the second partition file can be deleted.
[0114] It should be noted that the WebWorker in the embodiments of this specification follows a transaction wrapping mechanism when processing files to ensure that the file processing operation is executed successfully. If an exception occurs during the execution process, it will roll back to before the file processing and re-execute the file processing to prevent data anomalies.
[0115] In the embodiments described in this specification, WebWorker receives compression instructions sent by the foreground main thread, determines the main file and fragment files to be compressed according to the compression instructions, automatically concatenates the transaction data in the main file and fragment files in sequence, compresses the transaction data, and stores it in a new compressed file. WebWorker automatically obtains the main file and compressed file to ensure the integrity of the compressed data, and prevents data redundancy in local storage space by deleting the original main file and compressed file.
[0116] Please see Figure 10 , Figure 10 This is a flowchart illustrating a file processing method provided in an embodiment of this specification. Figure 10 As shown, the method in the embodiments of this specification may include the following steps S902-S908.
[0117] S902, when the seventh main file in the local storage space of the current end meets the preset upload conditions, determine the fourth user file corresponding to the seventh main file in the local storage space; Specifically, when the seventh main file in the local storage space of the front end meets the preset upload conditions, the fourth user file corresponding to the seventh main file is determined in the local storage space. Uploading refers to uploading the main file to the cloud storage space of the server. The preset upload conditions can be that the WebWorker receives a file upload command sent by the foreground main thread, the auxiliary file of the main file is complete and the information in the auxiliary file is complete, or the session duration corresponding to the main file reaches a preset duration. This embodiment of the specification does not limit these conditions.
[0118] S904, determine the third user's third user identifier and third authentication information from the fourth user file; Specifically, the third user's third user identifier and third authentication information are determined from the fourth user file. When uploading the main file, the user's identifier and authentication information need to be sent to the server simultaneously so that the server can authenticate the user, determine whether the user has permission to upload the file, and associate the transaction data in the main file with the user in the cloud storage space. The authentication information is the user's identity authentication information, which includes the user's login credentials, such as username, password, and temporary token. The token is a temporary credential for verifying the user's identity and authorization. It can be generated by the server and returned to the user when the user logs in for the first time, so that the user can use the token to prove their identity or obtain permissions in subsequent operations.
[0119] S906, If the third fragment file corresponding to the seventh main file does not exist in the local storage space, the seventh main file will be uploaded based on the third user identifier and the third authentication information; Specifically, the system queries the local storage space for the third fragment file corresponding to the seventh main file. If the third fragment file is not found, the system uploads the seventh main file based on the third user identifier and the third authentication information.
[0120] In one feasible implementation, if the third fragment file corresponding to the seventh master file does not exist in the local storage space, then the seventh transaction data in the seventh master file is obtained; the seventh transaction data is converted into first form data (FormData); the first form data, the third user identifier, and the third authentication information are uploaded to the server's cloud storage space, so that the server, after verifying the third authentication information, maps and stores the first form data and the third user in the cloud storage space; the seventh master file, the fourth user file, and the fourth metadata file corresponding to the seventh master file are deleted. FormData is a web interface for constructing form data, used to create and send form-formatted data, greatly simplifying the front-end file upload implementation process.
[0121] S908: If a third fragment file corresponding to the seventh main file exists in the local storage space, then the seventh main file and the third fragment file are uploaded based on the third user identifier and the third authentication information.
[0122] In one feasible implementation, if a third fragment file corresponding to the seventh master file exists in the local storage space, then the seventh transaction data in the seventh master file and the eighth transaction data in the third fragment file are obtained; the seventh transaction data and the eighth transaction data are concatenated in the local storage space to obtain the ninth transaction data; the ninth transaction data is converted into second form data; the second form data, the third user identifier, and the third authentication information are uploaded to the cloud storage space of the server, so that the server can map and store the second form data and the third user in the cloud storage space after verifying the third authentication information; the seventh master file, the third fragment file, the fourth user file, and the fourth metadata file corresponding to the seventh master file are deleted.
[0123] It should be noted that the WebWorker in the embodiments of this specification follows a transaction wrapping mechanism when processing files to ensure that the file processing operation is executed successfully. If an exception occurs during the execution process, it will roll back to before the file processing and re-execute the file processing to prevent data anomalies.
[0124] In the embodiments described in this specification, an automatic upload mechanism is set up in WebWorker. When the main file meets the preset upload conditions, WebWorker automatically obtains the user identifier and authentication information from the user file corresponding to the main file. If a corresponding fragment file is found for the main file, the transaction data in both the main file and the fragment file is uploaded; if no corresponding fragment file is found for the main file, the transaction data of the main file is uploaded. During the upload process, the transaction data is converted into unformed data, improving file upload efficiency. After the upload process, the main file and the corresponding auxiliary files are deleted to prevent data redundancy in the local storage space.
[0125] based on Figure 1 The system architecture diagram will be presented below, in conjunction with... Figure 11 This specification provides a detailed description of the document processing apparatus provided in the embodiments. It should be noted that... Figure 11 The file processing device in this specification is used to execute the file processing device described herein. Figures 2-10 The methods shown in the embodiments are illustrated for ease of explanation, showing only the parts related to the embodiments of this specification. For specific technical details not disclosed, please refer to this specification. Figures 2-10 The example shown.
[0126] Please see Figure 11 , Figure 11 This is a schematic diagram of the structure of a file processing device provided in an embodiment of this specification. Figure 11As shown, the file processing device 1 in the embodiments of this specification may include: an instruction receiving unit 11, a first processing unit 12, and a second processing unit 13.
[0127] The instruction receiving unit 11 is used to receive file processing instructions sent by the front-end main thread. The first processing unit 12 is used to determine the target file corresponding to the file processing instruction in the local storage space of the front end, and to perform first file processing on the target file based on the file processing instruction; The second processing unit 13 is used to obtain the associated file corresponding to the target file and perform second file processing on the associated file based on the first file processing.
[0128] Optionally, the first processing unit 12 is specifically used to obtain the first main file path carried by the file writing instruction if the file processing instruction is a file writing instruction; Create the first main file corresponding to the first main file path in the local storage space of the front end; If the first user corresponding to the file write instruction is logged in, then the first user identifier and the first transaction data carried by the file write instruction are written into the first main file; If the first user corresponding to the file write instruction is not logged in, the first transaction data carried by the file write instruction will be written to the first main file.
[0129] Optionally, the second processing unit 13 is specifically used to determine the first metafile path of the first metadata file corresponding to the first master file and the first user file path of the first user file corresponding to the first master file based on the first master file path. Create the first metadata file corresponding to the first metadata file path in the local storage space, and create the first user file corresponding to the first user file path in the local storage space; If the first user is logged in, then obtain the first user's first authentication information from the login status; Write the environment parameters corresponding to the first transaction data into the first metadata file, and write the first user identifier and the first authentication information into the first user file.
[0130] Optionally, the second processing unit 13 is specifically used to obtain the first transaction request corresponding to the first transaction data; Send the first transaction request, the first transaction data, and the first authentication information to the browser's server, so that the server can perform transaction operations on the first transaction data based on the first transaction request after verifying the first authentication information.
[0131] Optionally, the second processing unit 13 is specifically used to obtain the first transaction request corresponding to the first transaction data if the first user is not logged in. Write the environment parameters corresponding to the first transaction data and the first transaction request into the first metadata file; When the first user is detected to be logged in, obtain the first user's first user ID and first authentication information; Write the first user identifier and the first authentication information into the first user file; Send the first transaction request, the first transaction data, and the first authentication information to the browser's server, so that the server can perform transaction operations on the first transaction data based on the first transaction request after verifying the first authentication information.
[0132] Optionally, the first processing unit 12 is specifically used to obtain the second main file path carried by the file append instruction if the file processing instruction is a file append instruction; Determine the second main file corresponding to the second main file path in the local storage space of the front end; Write the second transaction data carried by the file append command into the second main file; Get the number of bytes in the second main file when writing the second transaction data.
[0133] Optionally, the second processing unit 13 is specifically used to determine the first segment file path of the first segment file corresponding to the second main file based on the second main file path if the number of bytes reaches a preset byte threshold. The preset byte threshold is the maximum number of bytes of the second main file and the first segment file. Create the first fragment file corresponding to the path of the first fragment file in the local storage space; Write the remaining transaction data from the second transaction data that was not written to the second main file to the first shard file.
[0134] Optionally, the first processing unit 12 is specifically used to obtain the third main file path carried by the file deletion instruction if the file processing instruction is a file deletion instruction; Delete the third main file corresponding to the third main file path in the local storage space of the front end.
[0135] Optionally, the second processing unit 13 is specifically used to determine the second metadata file and the second user file corresponding to the third master file in the local storage space; Delete the second metadata file and the second user file.
[0136] Optionally, the first processing unit 12 is specifically used to read the file path in the local storage space of the front end based on the directory reading instruction if the file processing instruction is a directory reading instruction; The file type of the target file corresponding to the file path is determined based on the file path.
[0137] Optionally, the file type is the main file type, and the second processing unit 13 is specifically used to obtain the third user file corresponding to the fourth main file if the file type indicates that the target file is the fourth main file. Retrieve user information contained in a third-party user file; If there is missing information in the user information, when the second user corresponding to the third user file is logged in, the second user identifier and / or second authentication information of the second user will be obtained. The missing information is supplemented based on the second user identifier and / or second authentication information; Send the path of the fourth main file to the foreground main thread.
[0138] Optionally, the second processing unit 13 is specifically used to obtain the third metadata file corresponding to the fourth master file and to obtain the third transaction data in the fourth master file; If a second transaction request corresponding to the third transaction data exists in the third metadata file, then obtain the second transaction request; Send a second transaction request, third transaction data, and second authentication information to the browser's server so that the server can perform transaction operations on the third transaction data based on the second transaction request after verifying the second authentication information.
[0139] Optionally, the file type is an auxiliary file type, which includes user file type, metadata file type and fragment file type; the second processing unit 13 is specifically used to query the fifth main file corresponding to the auxiliary file in the local storage space if the file type indicates that the target file is an auxiliary file; If the fifth main file is not found, delete the auxiliary files.
[0140] Optionally, the first processing unit 12 is specifically used to obtain the sixth main file path carried by the compression instruction if the file processing instruction is a compression instruction; Determine the sixth main file corresponding to the path of the sixth main file in the local storage space of the front end; Retrieve the fourth transaction data from the sixth master file.
[0141] Optionally, the second processing unit 13 is specifically used to obtain the second segment file corresponding to the sixth main file; Retrieve the fifth transaction data from the second fragment file; The data from the fourth and fifth transactions are concatenated in the local storage space to obtain the data from the sixth transaction. The sixth transaction data is compressed, and the compressed sixth transaction data is encapsulated in the compressed file corresponding to the sixth main file.
[0142] Optionally, the file processing device 1 is specifically used to determine the fourth user file corresponding to the seventh main file in the local storage space when the seventh main file in the local storage space meets the preset upload conditions; Determine the third user's third user identifier and third authentication information from the fourth user file; If the third fragment file corresponding to the seventh main file does not exist in the local storage space, the seventh main file will be uploaded based on the third user identifier and the third authentication information. If a third fragment file corresponding to the seventh main file exists in the local storage space, then the seventh main file and the third fragment file will be uploaded based on the third user identifier and the third authentication information.
[0143] Optionally, the file processing device 1 is specifically used to obtain the seventh transaction data in the seventh main file if the third fragment file corresponding to the seventh main file does not exist in the local storage space. Convert the seventh transaction data into the first form data; The first form data, the third user identifier, and the third authentication information are uploaded to the server's cloud storage space so that the server can map and store the first form data and the third user in the cloud storage space after verifying the third authentication information. Delete the seventh master file, the fourth user file, and the fourth metadata file corresponding to the seventh master file.
[0144] Optionally, the file processing device 1 is specifically used to obtain the seventh transaction data in the seventh main file and the eighth transaction data in the third fragment file if the third fragment file corresponding to the seventh main file exists in the local storage space. The seventh and eighth transaction data are concatenated in the local storage space to obtain the ninth transaction data. Convert the data from the ninth transaction into data from the second form; The second form data, the third user identifier, and the third authentication information are uploaded to the server's cloud storage space so that the server can map and store the second form data and the third user in the cloud storage space after verifying the third authentication information. Delete the seventh master file, the third fragment file, the fourth user file, and the fourth metadata file corresponding to the seventh master file.
[0145] In the embodiments of this specification, when a file processing instruction is received from the main thread of the browser frontend, the target file corresponding to the file processing instruction is determined in the local storage space of the frontend. Based on the file processing instruction, the target file undergoes first file processing to obtain the associated file corresponding to the target file. Based on the first file processing, the associated file undergoes second file processing. This embodiment of the specification is applied to the WebWorker of the frontend. A virtual file system is set up in the WebWorker. After processing the target file, the associated file corresponding to the target file is automatically processed. The file system is managed in an integrated manner in the browser frontend, ensuring file collaboration and consistency. When a file is written, a user file and metadata file corresponding to the main file are automatically created to avoid the main file existing but lacking the corresponding user file and metadata file. This constructs a virtual file system for integrated management, ensuring file collaboration and consistency. When a user is not logged in, the user's transaction request is temporarily stored in the metadata file so that when the user logs in later, the user identifier is associated with the transaction request, and the user's authentication information is obtained. The transaction request, authentication information, and transaction data are then resent to ensure timely processing of user transactions. When appending transaction data to the main file, the number of bytes in the main file is obtained. When the number of bytes in the main file reaches a preset byte threshold, a fragment file is created for the main file to prevent a single file from being too large and affecting read / write performance, thus improving the efficiency of concurrent file processing. After performing a deletion operation on the main file, the corresponding auxiliary file is automatically deleted, freeing up storage space and preventing data redundancy in local storage space. When executing a directory read command, if the target file is the main file, the user file of the main file is completed with information, and a transaction request is sent to the server in conjunction with the transaction request in the metadata file. Finally, the main file path of the main file is returned to the foreground main thread. Based on the target read command, the user information in the user file of the main file is automatically completed, and the transaction request in the metadata file is sent to the server to prevent data loss, enhance the robustness of the file system, and ensure the data integrity and consistency of the file system. When the target file is an auxiliary file, it is checked whether the auxiliary file has a corresponding main file. If no corresponding main file is found, the auxiliary file is deleted to prevent data silos and ensure the data integrity of the file system. When executing compression commands, the main file and compressed file are automatically retrieved to ensure the integrity of the compressed data. Redundancy in local storage space is prevented by deleting the original main file and compressed file. An automatic upload mechanism is configured in the WebWorker. When the main file meets preset upload conditions, the WebWorker automatically retrieves the user identifier and authentication information from the corresponding user file. If a corresponding fragment file is found for the main file, the transaction data in both the main file and the fragment file is uploaded; if no corresponding fragment file is found for the main file, the transaction data of the main file is uploaded. During upload processing, the transaction data is converted into unformed data, improving file upload efficiency.After uploading, the main file and its corresponding auxiliary files are deleted to prevent data redundancy in local storage. Furthermore, all file system processing is performed within the WebWorker, without relying on the foreground main thread, further preventing foreground main thread blocking and improving its rendering and interaction efficiency.
[0146] It should be noted that the file processing device provided in the above embodiments is only illustrated by the division of the above functional modules when executing the file processing method. In actual applications, the above functions can be assigned to different functional modules as needed, that is, the internal structure of the device can be divided into different functional modules to complete all or part of the functions described above. In addition, the file processing device and the file processing method embodiments provided in the above embodiments belong to the same concept, and the implementation process is detailed in the method embodiments, which will not be repeated here.
[0147] The embodiment numbers in this specification are for descriptive purposes only and do not represent the superiority or inferiority of the embodiments. In some cases, the actions or steps described in the claims can be performed in a different order than that shown in the embodiments and still achieve the desired result. Furthermore, the processes depicted in the drawings do not necessarily require a specific or sequential order to achieve the desired result. In some embodiments, multitasking and parallel processing are also possible or may be advantageous.
[0148] Please see Figure 12 , Figure 12 This is a schematic diagram of the structure of a computer device provided in the embodiments of this specification.
[0149] For example, such as Figure 12 As shown, the computer device 1200 includes a processor 1201 and a memory 1202, wherein the processor 1201 and the memory 1202 are electrically connected.
[0150] Processor 1201 is the control center of computer device 1200 and may include one or more processing cores. Processor 1201 connects to various parts of the computer device using various interfaces and lines. By running or calling computer programs stored in memory 1202 and calling data stored in memory 1202, it executes various functions of the computer device and processes data, thereby providing overall control of computer device 1200. Optionally, processor 1201 may be implemented using at least one hardware form of Digital Signal Processing (DSP), Field Programmable Gate Array (FPGA), or Programmable Logic Array (PLA). Processor 1201 may integrate one or more of the following: CPU, Graphics Processing Unit (GPU), and modem. The CPU primarily handles the operating system, user page, and applications; the GPU is responsible for rendering and drawing the displayed content; and the modem handles wireless communication. It is understood that the modem may also not be integrated into processor 1201 and may be implemented separately through a communication chip.
[0151] The memory 1202 can be used to store software programs and modules. The processor 1201 executes various functional applications and data processing by running the computer programs and modules stored in the memory 1202. The memory 1202 may mainly include a program storage area and a data storage area. The program storage area may store the operating system, computer programs required for at least one function, etc.; the data storage area may store data created based on the use of the computer device 1200, etc.
[0152] Furthermore, memory 1202 may include high-speed random access memory, and may also include non-volatile memory, such as at least one disk storage device, flash memory device, or other volatile solid-state storage device. Accordingly, memory 1202 may also include a memory controller to provide processor 1201 with access to memory 1202.
[0153] In a first feasible embodiment of the embodiments of this specification, the processor 1201 in the computer device 1200 loads the instructions corresponding to the processes of one or more computer programs into the memory 1202 according to the following steps, and the processor 1201 runs the computer programs stored in the memory 1202 to realize various functions, as follows: Receive file processing instructions sent by the front-end main thread; In the local storage space of the front end, determine the target file corresponding to the file processing instruction, and perform the first file processing on the target file based on the file processing instruction; Obtain the associated file corresponding to the target file, and perform second file processing on the associated file based on the first file processing.
[0154] Optionally, when the processor 1201 determines the target file corresponding to the file processing instruction in the local storage space at the front end, and performs the first file processing on the target file based on the file processing instruction, it specifically executes: If the file processing instruction is a file write instruction, then obtain the first main file path carried by the file write instruction; Create the first main file corresponding to the first main file path in the local storage space of the front end; If the first user corresponding to the file write instruction is logged in, then the first user identifier and the first transaction data carried by the file write instruction are written into the first main file; If the first user corresponding to the file write instruction is not logged in, the first transaction data carried by the file write instruction will be written to the first main file.
[0155] Optionally, when processor 1201 executes the process of obtaining the associated file corresponding to the target file and performing second file processing on the associated file based on the first file processing, it specifically performs the following: Based on the first master file path, determine the first metafile path of the first metadata file corresponding to the first master file, and the first user file path of the first user file corresponding to the first master file; Create the first metadata file corresponding to the first metadata file path in the local storage space, and create the first user file corresponding to the first user file path in the local storage space; If the first user is logged in, then obtain the first user's first authentication information from the login status; Write the environment parameters corresponding to the first transaction data into the first metadata file, and write the first user identifier and the first authentication information into the first user file.
[0156] Optionally, after executing the steps of writing the environment parameters corresponding to the first transaction data into the first metadata file and writing the first user identifier and the first authentication information into the first user file, the processor 1201 further executes: Obtain the first transaction request corresponding to the first transaction data; Send the first transaction request, the first transaction data, and the first authentication information to the browser's server, so that the server can perform transaction operations on the first transaction data based on the first transaction request after verifying the first authentication information.
[0157] Optionally, after executing the actions of creating the first metadata file corresponding to the first metafile path in the local storage space and creating the first user file corresponding to the first user file path in the local storage space, the processor 1201 further executes: If the first user is not logged in, then obtain the first transaction request corresponding to the first transaction data; Write the environment parameters corresponding to the first transaction data and the first transaction request into the first metadata file; When the first user is detected to be logged in, obtain the first user's first user ID and first authentication information; Write the first user identifier and the first authentication information into the first user file; Send the first transaction request, the first transaction data, and the first authentication information to the browser's server, so that the server can perform transaction operations on the first transaction data based on the first transaction request after verifying the first authentication information.
[0158] Optionally, when the processor 1201 determines the target file corresponding to the file processing instruction in the local storage space at the front end, and performs the first file processing on the target file based on the file processing instruction, it specifically executes: If the file processing instruction is a file append instruction, then obtain the path of the second main file carried by the file append instruction; Determine the second main file corresponding to the second main file path in the local storage space of the front end; Write the second transaction data carried by the file append command into the second main file; Get the number of bytes in the second main file when writing the second transaction data.
[0159] Optionally, when processor 1201 executes the process of obtaining the associated file corresponding to the target file and performing second file processing on the associated file based on the first file processing, it specifically performs the following: If the number of bytes reaches the preset byte threshold, the first fragment file path of the first fragment file corresponding to the second main file is determined based on the second main file path. The preset byte threshold is the maximum number of bytes in the second main file and the first fragment file. Create the first fragment file corresponding to the path of the first fragment file in the local storage space; Write the remaining transaction data from the second transaction data that was not written to the second main file to the first shard file.
[0160] Optionally, when the processor 1201 determines the target file corresponding to the file processing instruction in the local storage space at the front end, and performs the first file processing on the target file based on the file processing instruction, it specifically executes: If the file processing command is a file deletion command, then obtain the path of the third main file carried by the file deletion command; Delete the third main file corresponding to the third main file path in the local storage space of the front end.
[0161] Optionally, when processor 1201 executes the process of obtaining the associated file corresponding to the target file and performing second file processing on the associated file based on the first file processing, it specifically performs the following: Determine the second metadata file and the second user file corresponding to the third master file in the local storage space; Delete the second metadata file and the second user file.
[0162] Optionally, when the processor 1201 determines the target file corresponding to the file processing instruction in the local storage space at the front end, and performs the first file processing on the target file based on the file processing instruction, it specifically executes: If the file processing instruction is a directory read instruction, then the file path in the local storage space of the front end is read based on the directory read instruction; The file type of the target file corresponding to the file path is determined based on the file path.
[0163] Optionally, the file type is the primary file type. When processor 1201 executes the process of obtaining the associated file corresponding to the target file and performing secondary file processing on the associated file based on the first file processing, it specifically executes: If the file type indicates that the target file is the fourth main file, then obtain the third user file corresponding to the fourth main file; Retrieve user information contained in a third-party user file; If there is missing information in the user information, when the second user corresponding to the third user file is logged in, the second user identifier and / or second authentication information of the second user will be obtained. The missing information is supplemented based on the second user identifier and / or second authentication information; Send the path of the fourth main file to the foreground main thread.
[0164] Optionally, after performing the supplementation of missing information based on the second user identifier and / or second authentication information, the processor 1201 also performs: Obtain the third metadata file corresponding to the fourth master file, and obtain the third transaction data in the fourth master file; If a second transaction request corresponding to the third transaction data exists in the third metadata file, then obtain the second transaction request; Send a second transaction request, third transaction data, and second authentication information to the browser's server so that the server can perform transaction operations on the third transaction data based on the second transaction request after verifying the second authentication information.
[0165] Optionally, the file type is an auxiliary file type, which includes user file type, metadata file type, and fragment file type; when the processor 1201 executes the process of obtaining the associated file corresponding to the target file and performing the second file processing on the associated file based on the first file processing, it specifically executes: If the file type indicates that the target file is an auxiliary file, then search for the fifth main file corresponding to the auxiliary file in the local storage space; If the fifth main file is not found, delete the auxiliary files.
[0166] Optionally, when the processor 1201 determines the target file corresponding to the file processing instruction in the local storage space at the front end, and performs the first file processing on the target file based on the file processing instruction, it specifically executes: If the file processing instruction is a compression instruction, then obtain the path of the sixth main file carried by the compression instruction; Determine the sixth main file corresponding to the path of the sixth main file in the local storage space of the front end; Retrieve the fourth transaction data from the sixth master file.
[0167] Optionally, when processor 1201 executes the process of obtaining the associated file corresponding to the target file and performing second file processing on the associated file based on the first file processing, it specifically performs the following: Obtain the second fragment file corresponding to the sixth main file; Retrieve the fifth transaction data from the second fragment file; The data from the fourth and fifth transactions are concatenated in the local storage space to obtain the data from the sixth transaction. The sixth transaction data is compressed, and the compressed sixth transaction data is encapsulated in the compressed file corresponding to the sixth main file.
[0168] Optionally, the processor 1201 may also perform the following: when the seventh main file in the local storage space of the current end meets the preset upload conditions, determine the fourth user file corresponding to the seventh main file in the local storage space. Determine the third user's third user identifier and third authentication information from the fourth user file; If the third fragment file corresponding to the seventh main file does not exist in the local storage space, the seventh main file will be uploaded based on the third user identifier and the third authentication information. If a third fragment file corresponding to the seventh main file exists in the local storage space, then the seventh main file and the third fragment file will be uploaded based on the third user identifier and the third authentication information.
[0169] Optionally, when processor 1201 performs the upload process for the seventh main file based on the third user identifier and third authentication information if the third fragment file corresponding to the seventh main file does not exist in the local storage space, it specifically executes: If the third shard file corresponding to the seventh master file does not exist in the local storage space, then the seventh transaction data in the seventh master file is retrieved. Convert the seventh transaction data into the first form data; The first form data, the third user identifier, and the third authentication information are uploaded to the server's cloud storage space so that the server can map and store the first form data and the third user in the cloud storage space after verifying the third authentication information. Delete the seventh master file, the fourth user file, and the fourth metadata file corresponding to the seventh master file.
[0170] Optionally, when processor 1201 performs the upload process for the seventh main file and the third fragment file based on the third user identifier and third authentication information if the third fragment file corresponding to the seventh main file exists in the local storage space, it specifically executes the following: If the third shard file corresponding to the seventh master file exists in the local storage space, then the seventh transaction data in the seventh master file and the eighth transaction data in the third shard file are obtained. The seventh and eighth transaction data are concatenated in the local storage space to obtain the ninth transaction data. Convert the data from the ninth transaction into data from the second form; The second form data, the third user identifier, and the third authentication information are uploaded to the server's cloud storage space so that the server can map and store the second form data and the third user in the cloud storage space after verifying the third authentication information. Delete the seventh master file, the third fragment file, the fourth user file, and the fourth metadata file corresponding to the seventh master file.
[0171] In the embodiments of this specification, when a file processing instruction is received from the main thread of the browser frontend, the target file corresponding to the file processing instruction is determined in the local storage space of the frontend. Based on the file processing instruction, the target file undergoes first file processing to obtain the associated file corresponding to the target file. Based on the first file processing, the associated file undergoes second file processing. This embodiment of the specification is applied to the WebWorker of the frontend. A virtual file system is set up in the WebWorker. After processing the target file, the associated file corresponding to the target file is automatically processed. The file system is managed in an integrated manner in the browser frontend, ensuring file collaboration and consistency. When a file is written, a user file and metadata file corresponding to the main file are automatically created to avoid the main file existing but lacking the corresponding user file and metadata file. This constructs a virtual file system for integrated management, ensuring file collaboration and consistency. When a user is not logged in, the user's transaction request is temporarily stored in the metadata file so that when the user logs in later, the user identifier is associated with the transaction request, and the user's authentication information is obtained. The transaction request, authentication information, and transaction data are then resent to ensure timely processing of user transactions. When appending transaction data to the main file, the number of bytes in the main file is obtained. When the number of bytes in the main file reaches a preset byte threshold, a fragment file is created for the main file to prevent a single file from being too large and affecting read / write performance, thus improving the efficiency of concurrent file processing. After performing a deletion operation on the main file, the corresponding auxiliary file is automatically deleted, freeing up storage space and preventing data redundancy in local storage space. When executing a directory read command, if the target file is the main file, the user file of the main file is completed with information, and a transaction request is sent to the server in conjunction with the transaction request in the metadata file. Finally, the main file path of the main file is returned to the foreground main thread. Based on the target read command, the user information in the user file of the main file is automatically completed, and the transaction request in the metadata file is sent to the server to prevent data loss, enhance the robustness of the file system, and ensure the data integrity and consistency of the file system. When the target file is an auxiliary file, it is checked whether the auxiliary file has a corresponding main file. If no corresponding main file is found, the auxiliary file is deleted to prevent data silos and ensure the data integrity of the file system. When executing compression commands, the main file and compressed file are automatically retrieved to ensure the integrity of the compressed data. Redundancy in local storage space is prevented by deleting the original main file and compressed file. An automatic upload mechanism is configured in the WebWorker. When the main file meets preset upload conditions, the WebWorker automatically retrieves the user identifier and authentication information from the corresponding user file. If a corresponding fragment file is found for the main file, the transaction data in both the main file and the fragment file is uploaded; if no corresponding fragment file is found for the main file, the transaction data of the main file is uploaded. During upload processing, the transaction data is converted into unformed data, improving file upload efficiency.After uploading, the main file and its corresponding auxiliary files are deleted to prevent data redundancy in local storage. Furthermore, all file system processing is performed within the WebWorker, without relying on the foreground main thread, further preventing foreground main thread blocking and improving its rendering and interaction efficiency.
[0172] It should be understood that the apparatus provided in the embodiments of this specification is used to perform the above-described file processing method, and therefore can achieve the same effect as the above-described implementation method.
[0173] When using integrated units, the device may include a processing module and a storage module. When applied to a computer device, the processing module can be used to control and manage the operations of the computer device. The storage module can be used to support the computer device in executing relevant program code, etc.
[0174] The processing module may be a processor or a controller, which can implement or execute the various exemplary logic blocks, modules, and circuits described in conjunction with the disclosure herein. The processor may also be a combination of functions that implement computing capabilities, such as a combination of one or more microprocessors, a combination of digital signal processing (DSP) and a microprocessor, etc., and the storage module may be a memory.
[0175] In addition, the device provided in the embodiments of this specification may specifically be a chip, component or module. The chip may include a connected processor and a memory. The memory is used to store instructions. When the processor calls and executes the instructions, the chip can execute a file processing method provided in the above embodiments.
[0176] This specification also provides a computer-readable storage medium storing computer program code. When the computer program code is run on a computer, the computer executes the aforementioned method steps to implement a file processing method provided in the above embodiments.
[0177] This embodiment also provides a computer program product that, when run on a computer, causes the computer to perform the aforementioned related steps to implement a file processing method provided in the above embodiment.
[0178] In this embodiment, the device, computer-readable storage medium, computer program product, or chip are all used to execute the corresponding methods provided above. Therefore, the beneficial effects they can achieve can be referred to the beneficial effects in the corresponding methods provided above, and will not be repeated here.
[0179] Through the above description of the embodiments, those skilled in the art will understand that, for the sake of convenience and brevity, only the division of the above functional modules is used as an example. In actual applications, the above functions can be assigned to different functional modules as needed, that is, the internal structure of the device can be divided into different functional modules to complete all or part of the functions described above.
[0180] In the embodiments provided in this specification, it should be understood that the disclosed apparatus and methods can be implemented in other ways. For example, the apparatus embodiments described above are merely illustrative; for instance, the division of modules or units is only a logical functional division, and in actual implementation, there may be other division methods. For example, multiple units or components may be combined or integrated into another device, or some features may be ignored or not executed. Furthermore, the coupling or direct coupling or communication connection shown or discussed may be through some interfaces; the indirect coupling or communication connection between devices or units may be electrical, mechanical, or other forms.
[0181] The above description is merely a specific embodiment of this specification, but the scope of protection of this specification is not limited thereto. Any variations or substitutions that can be easily conceived by those skilled in the art within the scope of the technology disclosed in this specification should be included within the scope of protection of this specification. Therefore, the scope of protection of this specification should be determined by the scope of the claims.
Claims
1. A file processing method applied to a background thread in the front end of a browser, the method comprising: Receive file processing instructions sent by the front-end main thread; The target file corresponding to the file processing instruction is determined in the local storage space of the front end, and the first file processing is performed on the target file based on the file processing instruction; Obtain the associated file corresponding to the target file, and perform second file processing on the associated file based on the first file processing.
2. The method according to claim 1, wherein determining the target file corresponding to the file processing instruction in the local storage space of the front end, and performing first file processing on the target file based on the file processing instruction, comprises: If the file processing instruction is a file write instruction, then obtain the first main file path carried by the file write instruction; Create the first main file corresponding to the first main file path in the local storage space of the front end; If the first user corresponding to the file write instruction is logged in, then the first user identifier and the first transaction data carried by the file write instruction are written into the first main file; If the first user corresponding to the file write instruction is not logged in, the first transaction data carried by the file write instruction will be written into the first main file.
3. The method according to claim 2, wherein obtaining the associated file corresponding to the target file and performing second file processing on the associated file based on the first file processing includes: Based on the first master file path, determine the first metafile path of the first metadata file corresponding to the first master file, and the first user file path of the first user file corresponding to the first master file; Create the first metadata file corresponding to the first metadata file path in the local storage space, and create the first user file corresponding to the first user file path in the local storage space; If the first user is in the logged-in state, then obtain the first authentication information of the first user from the logged-in state; Write the environment parameters corresponding to the first transaction data into the first metadata file, and write the first user identifier and the first authentication information into the first user file.
4. The method according to claim 3, further comprising, after writing the environment parameters corresponding to the first transaction data into the first metadata file and writing the first user identifier and the first authentication information into the first user file: Obtain the first transaction request corresponding to the first transaction data; The first transaction request, the first transaction data, and the first authentication information are sent to the browser's server, so that the server, after verifying the first authentication information, performs a transaction operation on the first transaction data based on the first transaction request.
5. The method according to claim 3, wherein after creating the first metadata file corresponding to the first metadata file path in the local storage space, and creating the first user file corresponding to the first user file path in the local storage space, the method further includes: If the first user is in the unlogged-in state, then obtain the first transaction request corresponding to the first transaction data; Write the environment parameters corresponding to the first transaction data and the first transaction request into the first metadata file; When the first user is detected to be in the logged-in state, the first user identifier and first authentication information of the first user are obtained; Write the first user identifier and the first authentication information into the first user file; The first transaction request, the first transaction data, and the first authentication information are sent to the browser's server, so that the server, after verifying the first authentication information, performs a transaction operation on the first transaction data based on the first transaction request.
6. The method according to claim 1, wherein determining the target file corresponding to the file processing instruction in the local storage space of the front end, and performing first file processing on the target file based on the file processing instruction, comprises: If the file processing instruction is a file append instruction, then obtain the second main file path carried by the file append instruction; Determine the second main file corresponding to the second main file path in the local storage space of the front end; Write the second transaction data carried by the file append instruction into the second main file; The number of bytes in the second main file is obtained when writing the second transaction data.
7. The method according to claim 6, wherein obtaining the associated file corresponding to the target file and performing second file processing on the associated file based on the first file processing includes: If the number of bytes reaches a preset byte threshold, then the first segment file path of the first segment file corresponding to the second main file is determined based on the second main file path, and the preset byte threshold is the maximum number of bytes of the second main file and the first segment file; Create the first fragment file corresponding to the first fragment file path in the local storage space; Write the remaining transaction data from the second transaction data that was not written to the second main file into the first fragment file.
8. The method according to claim 1, wherein determining the target file corresponding to the file processing instruction in the local storage space of the front end, and performing first file processing on the target file based on the file processing instruction, comprises: If the file processing instruction is a file deletion instruction, then obtain the third main file path carried by the file deletion instruction; Delete the third main file corresponding to the third main file path in the local storage space of the front end.
9. The method according to claim 8, wherein obtaining the associated file corresponding to the target file and performing second file processing on the associated file based on the first file processing includes: Determine the second metadata file and the second user file corresponding to the third master file in the local storage space; Delete the second metadata file and the second user file.
10. The method according to claim 1, wherein determining the target file corresponding to the file processing instruction in the local storage space of the front end, and performing first file processing on the target file based on the file processing instruction, comprises: If the file processing instruction is a directory read instruction, then the file path in the local storage space of the front end is read based on the directory read instruction; The file type of the target file corresponding to the file path is determined based on the file path.
11. The method according to claim 10, wherein the file type is a primary file type, and the step of obtaining the associated file corresponding to the target file and performing second file processing on the associated file based on the first file processing includes: If the file type indicates that the target file is the fourth main file, then obtain the third user file corresponding to the fourth main file; Obtain the user information contained in the third user file; If there is missing information in the user information, then when the second user corresponding to the third user file is logged in, the second user identifier and / or second authentication information of the second user are obtained. The missing information is supplemented based on the second user identifier and / or the second authentication information; The path of the fourth main file is sent to the foreground main thread.
12. The method according to claim 11, wherein after supplementing the missing information based on the second user identifier and / or the second authentication information, it further comprises: Obtain the third metadata file corresponding to the fourth master file, and obtain the third transaction data in the fourth master file; If a second transaction request corresponding to the third transaction data exists in the third metadata file, then the second transaction request is obtained; The second transaction request, the third transaction data, and the second authentication information are sent to the browser's server, so that the server, after verifying the second authentication information, performs a transaction operation on the third transaction data based on the second transaction request.
13. The method according to claim 10, wherein the file type is an auxiliary file type, and the auxiliary file type includes user file type, metadata file type, and fragment file type; The step of obtaining the associated file corresponding to the target file and performing second file processing on the associated file based on the first file processing includes: If the file type indicates that the target file is an auxiliary file, then the fifth main file corresponding to the auxiliary file is queried in the local storage space; If the fifth main file is not found, the auxiliary file will be deleted.
14. The method according to claim 1, wherein determining the target file corresponding to the file processing instruction in the local storage space of the front end, and performing first file processing on the target file based on the file processing instruction, comprises: If the file processing instruction is a compression instruction, then obtain the sixth main file path carried by the compression instruction; Determine the sixth main file corresponding to the sixth main file path in the local storage space of the front end; Obtain the fourth transaction data from the sixth master file.
15. The method according to claim 14, wherein obtaining the associated file corresponding to the target file and performing second file processing on the associated file based on the first file processing includes: Obtain the second fragment file corresponding to the sixth main file; Obtain the fifth transaction data from the second fragment file; The fourth transaction data and the fifth transaction data are concatenated in the local storage space to obtain the sixth transaction data; The sixth transaction data is compressed, and the compressed sixth transaction data is encapsulated in the compressed file corresponding to the sixth main file.
16. The method according to claim 1, further comprising: When the seventh main file in the local storage space of the front end meets the preset upload conditions, the fourth user file corresponding to the seventh main file is determined in the local storage space; The third user's third user identifier and third authentication information are determined from the fourth user file; If the third fragment file corresponding to the seventh main file does not exist in the local storage space, the seventh main file is uploaded based on the third user identifier and the third authentication information. If the local storage space contains a third fragment file corresponding to the seventh main file, then the seventh main file and the third fragment file are uploaded based on the third user identifier and the third authentication information.
17. The method according to claim 16, wherein if the third fragment file corresponding to the seventh main file does not exist in the local storage space, then uploading the seventh main file based on the third user identifier and the third authentication information includes: If the third shard file corresponding to the seventh main file does not exist in the local storage space, then the seventh transaction data in the seventh main file is obtained; Convert the seventh transaction data into the first form data; The first form data, the third user identifier, and the third authentication information are uploaded to the cloud storage space of the server, so that after the server verifies the third authentication information, it maps and stores the first form data and the third user in the cloud storage space. Delete the seventh master file, the fourth user file, and the fourth metadata file corresponding to the seventh master file.
18. The method according to claim 16, wherein if a third fragment file corresponding to the seventh main file exists in the local storage space, then uploading the seventh main file and the third fragment file based on the third user identifier and the third authentication information includes: If the third shard file corresponding to the seventh main file exists in the local storage space, then the seventh transaction data in the seventh main file and the eighth transaction data in the third shard file are obtained. The seventh transaction data and the eighth transaction data are concatenated in the local storage space to obtain the ninth transaction data; Convert the ninth transaction data into second form data; The second form data, the third user identifier, and the third authentication information are uploaded to the cloud storage space of the server, so that after the server verifies the third authentication information, it maps and stores the second form data and the third user in the cloud storage space; Delete the seventh master file, the third fragment file, the fourth user file, and the fourth metadata file corresponding to the seventh master file.
19. A document processing apparatus, the apparatus comprising: The instruction receiving unit is used to receive file processing instructions sent by the front-end main thread of the front end; The first processing unit is configured to determine the target file corresponding to the file processing instruction in the local storage space of the front end, and perform first file processing on the target file based on the file processing instruction; The second processing unit is used to obtain the associated file corresponding to the target file and perform second file processing on the associated file based on the first file processing.
20. A computer device, comprising: Processor and memory; The memory stores a computer program adapted to be loaded by the processor and to execute the steps of the method as described in any one of claims 1 to 18.
21. A storage medium storing a computer program that, when executed by a processor, implements the steps of the method as claimed in any one of claims 1 to 18.
22. A computer program product comprising: A computer program, when executed by a processor of a computer device, causes the processor to perform the steps of the method as described in any one of claims 1 to 18.