Directory management method and device, electronic equipment and storage medium

By identifying and completing missing directories on the FTP server, the problem of file upload failure is solved, and efficient and accurate file storage and management are achieved.

CN120596440APending Publication Date: 2025-09-05JINAN INSPUR DATA TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202510716447.7
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-05-29
Publication Date
2025-09-05

AI Technical Summary

Technical Problem

During the FTP service file transfer process, client file uploads failed due to missing server directories, resulting in a low success rate.

Method used

By receiving file upload requests, identifying the file path, detecting missing directory information, and gradually completing the directory based on the missing information, it ensures that the file is uploaded to the complete directory.

Benefits of technology

The success rate of file upload has been improved from 5% to below 0.1%, ensuring accurate file storage and optimizing the storage structure to improve management efficiency.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120596440A_ABST
    Figure CN120596440A_ABST
Patent Text Reader

Abstract

The invention discloses a directory management method and device, electronic equipment and a storage medium, and relates to the technical field of computers, and the method comprises the steps: receiving a plurality of file uploading requests initiated by a connected client based on a file transfer protocol; identifying a file uploading path of a to-be-uploaded file carried by each file uploading request; missing information of all levels of directories in the file directories corresponding to all the file uploading paths is detected; the file catalog is complemented based on the missing information of the catalog at each level, and the corresponding to-be-uploaded file is uploaded to the complemented file catalog, so that the problem that in the file transmission process, once the catalog of the server side is missing, the client side can directly receive the error information of file transmission failure, and the file transmission efficiency is improved is solved. Therefore, the file uploading success rate of the client is low, and the technical effect of improving the file transmission reliability and efficiency is achieved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of computer technology, and in particular to directory management methods, devices, electronic devices, and storage media. Background Art

[0002] With the rapid development of the internet, file transfer has become an integral part of daily work. The File Transfer Protocol (FTP) plays a crucial role in cross-platform file sharing. However, when a directory is missing on the server side during file transfers, the client will receive an error message indicating a file transfer failure, resulting in a low file upload success rate. Summary of the Invention

[0003] The present application provides a directory management method, device, electronic device and storage medium to at least solve the problem in the related art that during the file transfer process of the FTP service, once there is a directory missing on the server side, the client will directly receive an error message that the file transfer failed, resulting in a low file upload success rate on the client.

[0004] This application provides a directory management method, which is applied to the server, including:

[0005] Receive multiple file upload requests initiated by the connected client based on the file transfer protocol;

[0006] Identify the file upload path of the file to be uploaded carried in each file upload request;

[0007] Detect missing information of directories at all levels in the file directory corresponding to each file upload path;

[0008] The file directory is completed based on the missing information of the directories at all levels, and the corresponding files to be uploaded are uploaded to the completed file directory.

[0009] In an optional implementation, detecting missing information of directories at all levels in the file directory corresponding to each file upload path includes:

[0010] Upload the file to be uploaded in the file directory corresponding to the file upload path and obtain the file upload result;

[0011] If the file upload result is upload failure, the directory at each level will be checked for missing information starting from the root directory corresponding to each file upload path.

[0012] In an optional implementation, the file directory is completed based on the missing information of the directories at all levels, and the corresponding files to be uploaded are uploaded to the completed file directory, including:

[0013] Generate the corresponding completed directory path based on the missing information of directories at all levels;

[0014] Create missing directories step by step according to the completion directory path to obtain the completion file directory;

[0015] Upload the file to be uploaded to the corresponding location in the completion file directory.

[0016] In an optional implementation, the file directory is completed based on the missing information of the directories at all levels, and the corresponding files to be uploaded are uploaded to the completed file directory, further comprising:

[0017] Compare any current file upload request among the multiple file upload requests with other file upload requests to obtain a request comparison result;

[0018] If the request comparison result indicates that the file upload path corresponding to the current file upload request is duplicated with the file upload path corresponding to other file upload requests, then the file directories are merged and completed based on the missing information of the directories at all levels in the file directory corresponding to the current file upload request and the missing information of the directories at all levels in the file directory corresponding to the other file upload requests to obtain a merged and completed file directory;

[0019] Upload the file to be uploaded corresponding to the current file upload request to the corresponding location under the merged and completed file directory.

[0020] In an optional embodiment, the file directory is merged and completed based on the missing information of the directories at all levels in the file directory corresponding to the current file upload request and the missing information of the directories at all levels in the file directory corresponding to other file upload requests, to obtain a merged and completed file directory, including:

[0021] Identify missing parts of directories at all levels in the file directories corresponding to the current file upload request and other file upload requests;

[0022] Integrate the identified missing information of directories at all levels, and merge and complete the file directories based on the integrated missing information.

[0023] In an optional implementation, uploading the file to be uploaded corresponding to the current file upload request to a corresponding location in the merged and completed file directory includes:

[0024] Obtain the available file storage space corresponding to the merged and completed file directory and the file space required for the file to be uploaded corresponding to the current file upload request;

[0025] If the available file storage space is greater than or equal to the file required space, the file to be uploaded will be uploaded to the corresponding location under the merged and completed file directory;

[0026] If the available file storage space is less than the file required space, an insufficient storage space prompt message is generated and fed back to the connected client to prompt the user to expand the storage space or delete some files to free up storage space.

[0027] In an optional implementation, the file directory is completed based on the missing information of the directories at all levels, and the corresponding files to be uploaded are uploaded to the completed file directory, further comprising:

[0028] Analyze the missing information of directories at all levels to obtain the missing directory levels and corresponding directory names;

[0029] The missing directory levels and corresponding directory names obtained by analysis are stored in a list form to obtain a missing directory information list;

[0030] Based on the missing directory information list, create the missing directories level by level until all missing directory levels are completed to obtain the completed file directory;

[0031] Based on the completed file directory, a storage file corresponding to the file to be uploaded is created, and the file content of the file to be uploaded is uploaded to the storage file.

[0032] This application also provides a directory management device, including:

[0033] The request acquisition module is used to receive multiple file upload requests initiated by the connected client based on the file transfer protocol;

[0034] A path identification module is used to identify the file upload path of the file to be uploaded carried in each file upload request;

[0035] An information detection module is used to detect missing information in directories at all levels in the file directory corresponding to each file upload path;

[0036] The directory completion module is used to complete the file directory based on the missing information of directories at all levels, and upload the corresponding files to be uploaded to the completed file directory.

[0037] The present application also provides an electronic device, comprising: a memory for storing a computer program; and a processor for implementing the steps of any of the above-mentioned directory management methods when executing the computer program.

[0038] The present application also provides a computer-readable storage medium, in which a computer program is stored. When the computer program is executed by a processor, the steps of any of the above-mentioned directory management methods are implemented.

[0039] The present application also provides a computer program product, including a computer program, which implements the steps of any of the above-mentioned directory management methods when executed by a processor.

[0040] Through this application, by comparing the read cache flag bit with the read group flag bit, the read status of the cached data can be accurately determined and corresponding feedback information can be generated. When an over-read error or under-read error is detected, corresponding measures can be taken, such as discarding the erroneous cached data or reading in the unread cached data, to ensure the accuracy of data reading. In addition, through the pre-read mechanism, the cached data can be read in advance, further improving the efficiency of data processing. Therefore, the technical problem of read and write errors that are prone to occur in the dual FIFO structure when processing data can be solved, achieving the technical effect of improving the accuracy and efficiency of data processing. BRIEF DESCRIPTION OF THE DRAWINGS

[0041] In order to more clearly illustrate the embodiments of the present application, the following is a brief introduction to the drawings required for use in the embodiments. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without any creative work.

[0042] Figure 1 A flowchart of the directory management method provided in an embodiment of the present application;

[0043] Figure 2 A flowchart of another directory management method provided in an embodiment of the present application;

[0044] Figure 3 An example diagram of an application of the directory management method provided in an embodiment of the present application;

[0045] Figure 4 A structural block diagram of the directory management device provided in an embodiment of the present application;

[0046] Figure 5 A schematic structural diagram of an electronic device is provided for an embodiment of the present application. DETAILED DESCRIPTION

[0047] The following will be combined with the accompanying drawings in the embodiments of this application to clearly and completely describe the technical solutions in the embodiments of this application. Obviously, the embodiments described are only part of the embodiments of this application, not all of them. Based on the embodiments in this application, all other embodiments obtained by ordinary technicians in this field without making creative efforts are within the scope of protection of this application.

[0048] It should be noted that, in the description of this application, the terms "comprises," "includes," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or device comprising a series of elements includes not only those elements, but also other elements not explicitly listed, or elements inherent to such process, method, article, or device. The terms "first," "second," etc., in this application are used to distinguish similar objects, and are not used to describe a particular order or sequence.

[0049] In order to enable those skilled in the art to better understand the present application, the present application is further described in detail below with reference to the accompanying drawings and specific implementation methods.

[0050] According to an embodiment of the present invention, an embodiment of a directory management method is provided. It should be noted that the steps shown in the flowchart of the accompanying drawings can be executed in a computer system such as a set of computer executable instructions, and although a logical order is shown in the flowchart, in some cases, the steps shown or described can be executed in an order different from that shown here.

[0051] The present disclosure provides a directory management method applied to a server, which may include but is not limited to a computer, a server, or other equipment with data processing capabilities. Figure 1 , which is a flow chart of a directory management method provided in some embodiments of the present disclosure. Figure 1 In the method for managing a directory, the steps may include:

[0052] Step 110: Receive multiple file upload requests initiated by the connected client based on the file transfer protocol.

[0053] As described above, by receiving multiple file upload requests initiated by the connected client based on the file transfer protocol, batch upload processing of multiple files can be achieved.

[0054] In some optional implementations, when receiving multiple file upload requests initiated by a connected client based on a file transfer protocol, each received file upload request can be verified to ensure the validity and legality of the request. The verification process can include authenticating the sender of the file upload request to ensure that it has the authority to upload the file; it can also check the content of the file upload request to confirm whether the request contains complete file information and a legal file path, etc. If the verification is successful, the subsequent file upload process will continue; if the verification fails, a verification failure prompt message will be generated and fed back to the connected client to prompt the user to re-initiate the file upload request or make corresponding adjustments. This ensures the security and reliability of file uploads and prevents illegal or invalid file upload requests from causing unnecessary burdens or risks to the server.

[0055] Specifically, the verification process may include digital signatures, certificate verification, and access control lists to ensure the authenticity of the sender of the file upload request. Furthermore, when inspecting the content of the file upload request, the file information in the request may be individually verified, including but not limited to the file name, file size, file type, and file path, to ensure the integrity and legality of the file information in the request.

[0056] Step 120: Identify the file upload path of the file to be uploaded carried in each file upload request.

[0057] As mentioned above, by identifying the file upload path of the file to be uploaded carried by each file upload request, the expected storage location of each file to be uploaded in the target storage location can be determined, which provides the basis for subsequent directory completion and file upload. It ensures that the file can be placed accurately in the location expected by the user.

[0058] In some optional embodiments, during the process of identifying the file upload path of the file to be uploaded carried in each file upload request, the file upload path may also be format-checked to ensure that the path format is correct and meets the server's requirements. If the file upload path format is correct, the subsequent steps will be executed. If the file upload path format is incorrect, a format error prompt message will be generated and fed back to the connected client to prompt the user to modify the file upload path, thereby ensuring the accuracy of the file upload path and avoiding problems such as file upload failure or incorrect storage location caused by path errors.

[0059] Specifically, format validation can include checking the character encoding, path separators, and file name length of the file upload path to ensure path compliance and accessibility. For example, the path can be verified to see if it contains illegal characters or exceeds the maximum length allowed by the system. If the path does not meet the server's requirements, an error message will be immediately fed back to guide the user to set the correct path, thereby ensuring smooth file upload.

[0060] Step 130: Detect missing information of directories at all levels in the file directory corresponding to each file upload path.

[0061] As described above, by detecting missing information of directories at all levels in the file directory corresponding to each file upload path, it is possible to determine which directories in the file directory do not exist in the target storage location, thereby providing a basis for subsequent directory completion operations.

[0062] In some optional implementations, when detecting missing information for directories at all levels in the file directory corresponding to each file upload path, the file to be uploaded can be uploaded to the file directory corresponding to the file upload path to obtain a file upload result. If the file upload result indicates that the upload failed, the missing information for each level of directory is checked, starting from the root directory corresponding to each file upload path. If a directory at a certain level is missing, the missing information for that level is recorded, and the next level of directory is checked again until all levels of directories are checked and the complete missing directory information is obtained. This allows the precise identification of missing parts in the file directory, providing accurate information support for subsequent completion operations.

[0063] Specifically, during the process of detecting missing information, the hierarchical relationships of the missing directories can be further analyzed to determine the hierarchical structure at which the missing directories are missing. This helps to create the missing directories step by step according to the correct hierarchical relationship when completing the directories, ensuring that the completed file directory structure is complete and meets the user's expectations. In addition, by recording the missing directory information corresponding to each file upload request, the missing directories can be quickly identified and completed for the same or similar file upload paths during subsequent file uploads, improving file upload efficiency.

[0064] Step 140: Complete the file directory based on the missing information of the directories at all levels, and upload the corresponding files to be uploaded to the completed file directory.

[0065] As described above, by completing the file directory based on missing information at each level and uploading the corresponding files to be uploaded to the completed file directory, we can avoid the problem of the FTP service directly receiving file transfer failure error messages when there is a missing directory on the server during the file transfer process, which leads to a low client file upload success rate. This can reduce the failure rate of millions of files uploaded from 5% to below 0.1%. At the same time, it can ensure that the uploaded files are accurately placed in the user's expected location and the file directory structure is intact, facilitating subsequent file management and access.

[0066] In some optional implementations, when the file directory is completed based on the missing information of directories at all levels and the corresponding files to be uploaded are uploaded to the completed file directory, the corresponding completed directory path can be generated according to the missing information of directories at all levels; the missing directories are created step by step according to the completed directory path to obtain the completed file directory; and the files to be uploaded are uploaded to the corresponding locations under the completed file directory.

[0067] Specifically, after detecting the missing information of directories at all levels in the file directory corresponding to each file upload path, it can be created step by step according to the hierarchical relationship of the directory to ensure the accuracy and completeness of the directory structure. During the creation process, if an existing directory is encountered, the creation of the directory is skipped to avoid repeated operations. At the same time, for each created directory, its creation time and creator information can be recorded for subsequent management and tracing. After completing the file directory, the file to be uploaded is uploaded to the corresponding position under the completed file directory according to its original file path or the path specified by the user. In this way, not only can it be ensured that the file can be placed accurately in the location expected by the user, but the structure of the file directory can also be kept intact, thereby improving the efficiency and accuracy of file management.

[0068] Furthermore, during the process of completing the directory and uploading files, the progress of the file upload can be monitored in real time and upload progress information can be generated. The upload progress information may include the number of files uploaded, the upload speed, the remaining upload time, etc., so that users can understand the progress of the file upload at any time. At the same time, when the file upload is completed, an upload success prompt message can be generated and fed back to the connected client to inform the user that the file has been successfully uploaded to the server. In addition, in order to further improve the efficiency and reliability of file uploads, a file upload queue can be set up on the server to queue the files to be uploaded. According to factors such as the file priority and size, the order of file upload can be reasonably arranged to ensure that important or urgent files can be uploaded first, thereby meeting the different needs of users.

[0069] In some optional implementations, when the file directory is completed based on the missing information of directories at all levels and the corresponding files to be uploaded are uploaded to the completed file directory, any current file upload request among multiple file upload requests can also be compared with other file upload requests to obtain a request comparison result; if the request comparison result indicates that the file upload path corresponding to the current file upload request and the file upload path corresponding to other file upload requests are repeated, the file directory is merged and completed based on the missing information of directories at all levels in the file directory corresponding to the current file upload request and the missing information of directories at all levels in the file directory corresponding to the other file upload requests to obtain a merged and completed file directory; the files to be uploaded corresponding to the current file upload request are uploaded to the corresponding position under the merged and completed file directory.

[0070] Specifically, in the process of merging and completing directories, the range of directories that need to be merged and completed can be determined by analyzing the common parent directory hierarchy of the file upload paths corresponding to multiple file upload requests. For example, if the file upload path corresponding to the current file upload request is " / data / projectA / docs / 2024", and the path corresponding to another file upload request is " / data / projectA / report / Q2", then the common parent directory is " / data / projectA". At this time, the missing directory structures in the two requests can be jointly analyzed. If the "docs / 2024" and "report / Q2" subdirectories are missing under " / data / projectA", two sets of directory branches are created simultaneously through a single completion operation, thereby reducing the number of repeated traversals of the file system. This batch completion mechanism not only reduces the system I / O overhead, but also optimizes the storage structure through path similarity analysis.

[0071] Furthermore, when writing files to be uploaded to the completion directory, a segmented lock mechanism can be used to control the concurrency of the target directory. When multiple clients simultaneously request to write files to the same parent directory, the server locks the target directory partitions based on the file hash value, so that different files can be written to different partitions in parallel without waiting for a global lock. For example, the directory is divided into 26 letter sub-partitions, and the write area is allocated according to the first letter of the file name. This significantly improves the throughput in high-concurrency scenarios while ensuring data consistency. After the write is completed, the partition lock is automatically released, and the directory metadata version number is updated to notify all clients to synchronize the latest status.

[0072] For large file uploads, if the server detects that a single file exceeds a preset threshold, it can split the uploaded file into several fixed-size data blocks. Each block generates an independent checksum and records the shard sequence number. A hidden metadata file is created when the directory is completed to store shard mappings and integrity verification information. Once all shards have been successfully uploaded, they are reassembled into a complete file through atomic operations. This ensures reliable transmission through shard retransmission even in abnormal situations such as network outages, avoiding the additional overhead of rolling back the entire operation due to a single transmission failure.

[0073] In some optional implementations, the file directory is merged and completed based on the missing information of the directories at all levels in the file directory corresponding to the current file upload request and the missing information of the directories at all levels in the file directory corresponding to other file upload requests. When the merged and completed file directory is obtained, the missing parts of the directories at all levels in the file directory corresponding to the current file upload request and the other file upload requests can be identified; the identified missing information of the directories at all levels is integrated, and the file directory is merged and completed based on the integrated missing information.

[0074] Specifically, the server can perform incremental comparison based on the preset directory version identifier, and generate a set of differential paths by traversing the nodes of the directory tree to be completed and the existing directory tree. When it is detected that the missing directories submitted concurrently by multiple clients have overlapping paths, a timestamp arbitration mechanism or a priority marking strategy is used to eliminate the completion conflict, ensuring that the final merged directory meets the directed acyclic graph structural constraints. For directory nodes with version differences, the directory attributes corresponding to the latest modification timestamp will be retained, and the version evolution trajectory will be recorded in the metadata layer for audit tracing. After the completion operation is completed, the asynchronous verification thread is triggered, and the hierarchical hash tree structure is used to verify the integrity of the reorganized directory, and the verification results are persistently stored in the form of transaction logs to the distributed coordination service.

[0075] In some optional implementations, when the file to be uploaded corresponding to the current file upload request is uploaded to the corresponding location under the merged and completed file directory, the available file storage space corresponding to the merged and completed file directory and the file requirement space of the file to be uploaded corresponding to the current file upload request can be obtained; if the available file storage space is greater than or equal to the file requirement space, the file to be uploaded is uploaded to the corresponding location under the merged and completed file directory; if the available file storage space is less than the file requirement space, an insufficient storage space prompt message is generated and fed back to the connected client to prompt the user to expand the storage space or delete some files to free up storage space.

[0076] Specifically, after receiving a file upload request, the server will first calculate the file space requirements for the file to be uploaded, including the file size and the additional metadata storage space that may be required. The server will then query the available file storage space corresponding to the merged and completed file directory. If the available space is sufficient, the server will start the file upload process and place the file to be uploaded in the correct location under the merged and completed file directory, and update the metadata of the storage system to reflect this change. If the server finds that the available file storage space is insufficient, it will generate a prompt message of insufficient storage space, including detailed information on the current storage space status, the amount of additional space required, and possible solutions (such as expansion suggestions or suggestions for deleting unnecessary files). The server will then feed this prompt information back to the client that initiated the file upload request, and the client is responsible for displaying this information in a user-friendly manner so that the user can take appropriate actions to resolve the problem of insufficient storage space.

[0077] In some optional implementations, when the server detects that multiple clients are concurrently creating directories with the same name, it will automatically generate a temporary directory with a timestamp and initiate a negotiation protocol. Specifically, the server first atomically registers the target directory path through the distributed lock service. If the registration is successful, the directory creation is immediately executed. If the path is detected to be occupied, a directory status query request is broadcast to all relevant clients. Based on the priority identifiers returned by each client (such as lease expiration time and transaction sequence number), arbitration is performed to ultimately determine the valid directory structure version, effectively avoiding the problem of inconsistent directory hierarchies caused by multi-node operations.

[0078] During the directory completion operation, the server monitors the storage system's capacity in real time. When the remaining space on the target storage volume is detected to be below the preset threshold, a space reclamation policy is automatically triggered: Prioritizing the cleanup of discarded files in the temporary directory that have exceeded their retention period, the server then sorts the existing files in the completion directory using a least recently used algorithm based on their most recently accessed timestamps, migrating cold data to the archive storage tier. Simultaneously, a capacity warning event is generated, which is pushed to the system administrator via the management interface. The server also dynamically adjusts the number of concurrent file upload requests to prevent service interruptions caused by storage overload.

[0079] In a distributed file system environment, the server generates a global namespace snapshot when creating a complete directory. This snapshot records the directory node topology, access control lists, and file distribution topology information, and uses an improved hash tree structure for version management. When directory status differences arise between cluster nodes, the inconsistency can be quickly located by comparing the hash tree root hash values ​​held by each node. A master node is then elected based on a consensus algorithm to synchronize status, ensuring strong consistency in the directory structure across regional deployments.

[0080] To enhance security, all directory creation operations are cryptographically signed by a hardware security module. Each newly created directory node generates a unique X.509 digital certificate containing a hash digest of the directory path, the creator's identity, and a validity window. Subsequent file uploads must verify the target directory's digital certificate chain to prevent malicious nodes from forging the directory structure and conducting man-in-the-middle attacks. Furthermore, directory metadata is protected using attribute-based encryption, ensuring that only clients meeting specific access policies can parse the directory's complete hierarchical information.

[0081] The server can also roll back directory operations, persistently recording the pre-image data of each completion operation in the transaction log. When an abnormal interruption in the directory completion process is detected, the server automatically parses the unfinished transaction log entries and performs compensation operations in reverse order: deleting the created empty directory nodes, restoring the modified directory permissions, and rolling back the server-side file system's index node allocation status. This ensures that the file system's directory structure maintains transactional consistency even in the event of a power failure or server-side system crash.

[0082] In summary, the directory management method provided by the present invention can effectively solve the problem of missing directories on the server side during the file upload process, and improve the success rate and efficiency of file upload. By analyzing the missing information of directories at all levels in detail and creating missing directories step by step according to the correct hierarchical relationship, it can ensure that the completed file directory structure is complete and meets the user's expectations, while avoiding the problem of file upload failure caused by competition for parent directory creation when uploading files at high concurrency. At the same time, by recording the missing directory information corresponding to each file upload request, the missing directory can be quickly identified and completed, further improving the efficiency of file upload.

[0083] Figure 2 FIG. 1 is a flow chart showing another embodiment of the directory management method of the present invention. Figure 2 As shown, the method includes the following steps:

[0084] Step 210: Receive multiple file upload requests initiated by the connected client based on the file transfer protocol.

[0085] For details, please see Figure 1 Step 110 of the illustrated embodiment will not be described in detail here.

[0086] Step 220: Identify the file upload path of the file to be uploaded carried in each file upload request.

[0087] For details, please see Figure 1 Step 120 of the illustrated embodiment will not be described in detail here.

[0088] Step 230: Detect missing information of directories at all levels in the file directory corresponding to each file upload path.

[0089] For details, please see Figure 1 Step 130 of the illustrated embodiment will not be described in detail here.

[0090] Step 240: Complete the file directory based on the missing information of the directories at all levels, and upload the corresponding files to be uploaded to the completed file directory.

[0091] Specifically, the above step 240 includes:

[0092] Step 2401: Analyze missing information of directories at all levels to obtain missing directory levels and corresponding directory names;

[0093] Step 2402: Store the missing directory levels and corresponding directory names obtained through analysis in a list format to obtain a missing directory information list;

[0094] Step 2403: Based on the missing directory information list, create the missing directories level by level until all missing directory levels are completed to obtain a completed file directory.

[0095] Step 2404: Based on the completed file directory, a storage file corresponding to the file to be uploaded is created, and the file content of the file to be uploaded is uploaded to the storage file.

[0096] Specifically, you can first scan the directory structure of the entire file system and compare it with the preset standard directory structure to identify the missing parts in each level of the directory. For each missing directory level, generate a corresponding directory name based on its parent directory and the required directory naming rules. Combine these missing directory levels and corresponding directory names into entries and store them in a list to form a list of missing directory information. Then, based on this list, starting from the highest missing level, create missing directories step by step to ensure that each level of directory is correctly completed according to the information in the list. When all missing directory levels are completed, the entire file directory structure meets the preset standards. At this time, based on the completed file directory, create a corresponding storage location for the file to be uploaded, that is, a storage file. Finally, copy or move the entire content of the file to be uploaded to this storage file to complete the file upload process.

[0097] Furthermore, when uploading the contents of a file to be uploaded to a storage file, the format type of the uploaded file can be detected first. For text files, the content is directly written to the target storage file. For image or video files, factors such as file size and resolution need to be comprehensively considered, and appropriate storage measures, such as compression or segmented storage, should be adopted. In addition, to ensure the security and integrity of the file, encryption and verification operations should be implemented during the upload process to prevent data leakage or corruption. After the file upload is completed, the file directory information is synchronously updated to ensure that it matches the actual storage status.

[0098] In some optional implementations, when creating a storage file corresponding to the file to be uploaded, the server will first check the legality and uniqueness of the file name to avoid upload failures caused by file name conflicts. If the file name is illegal or a file with the same name already exists, the server will generate a corresponding error message and feedback it to the client, prompting the user to modify the file name and upload again. For legal and unique file names, the server will create a corresponding storage file in the completed file directory and start the file content upload process. During the upload process, the server will record the upload progress and verify the integrity of the file content in real time to ensure that the uploaded file is exactly the same as the file sent by the client. Once the upload is complete, the server will update the metadata of the file system, mark the file as uploaded, and notify the client that the upload is successful. In addition, the server will also record the successfully uploaded file information in the log for subsequent auditing and tracking.

[0099] In some optional implementations, if a directory with the same name already exists during directory completion, the creation of that directory is skipped, avoiding resource waste caused by duplicate creation. Furthermore, to improve file upload efficiency, multi-threaded or asynchronous upload methods can be used to process multiple file upload requests simultaneously, reducing user wait time. After a file upload is complete, a corresponding upload record is generated, including information such as the upload time, uploaded file name, and upload results, to facilitate subsequent query and management by users.

[0100] In summary, the directory management method provided by the present invention ensures that files can be accurately stored in the expected location by accurately identifying and completing missing directory levels, avoiding the problem of file upload failure or storage location error due to incomplete directory structure. At the same time, by adopting multi-threaded or asynchronous upload methods, the file upload time is further shortened and the user experience is improved. In addition, the server actively detects whether each level of directory in the file path exists, and automatically creates and retries file writing when missing, ensuring the upload success rate in high-concurrency scenarios, while reducing the problem of file upload failure caused by competition for parent directory creation in high-concurrency file upload scenarios.

[0101] See also Figure 3As an example, when the FileZilla client initiates a multi-file upload request to the VSFTPD server based on the File Transfer Protocol, the file upload path to be uploaded by FileZilla client thread A is / a / b / file1.txt, and the file upload path to be uploaded by FileZilla client thread B is / a / b / file2.txt:

[0102] Thread A initiates a directory switch request (CWD / a / b). The client first attempts to switch to the target directory ( / a / b). If the directory does not exist, the server returns a 550 "Failed to change directory" error. The client then returns to the parent directory (CWD / a). If successful, it sends the create directory command (MKDb) to create the missing directory. After the directory is successfully created, it resends the directory switch request (CWD / a / b) and executes the file1.txt upload request (STOR file1.txt). A file metadata check reveals that Thread B is also uploading a file with the same path. After the directory switch request (CWD / a / b) fails, it sends the request for a specified file (SIZE file2.txt) and the get specified file command (MDTM file2.txt) to check whether the file exists. The server returns a 550 "File not found" error. Thread B then directly initiates the file2.txt upload request (STOR file2.txt). In the STOR file2.txt upload request for file2.txt, the server first creates / a / b / file2.txt. However, the parent directory of file2 does not exist at this time (thread A has not yet created parent directory b). Therefore, an error message is returned, with the error code ENOENT (553: Could not create file). The server determines the error type. If the error code is ENOENT, it loops through all the directories at the file level to check if they exist. If not, it creates the directories and then creates file2.txt. It then continues uploading the contents of file2.txt.

[0103] If thread B creates directory b before thread A, thread A will receive an error message when creating directory b, indicating that the directory already exists. Thread A then sends CDW / a / b / to switch to directory b, and the server returns a successful directory switch. Thread A then sends a request to create / a / b / file1.txt, and the server returns a successful file upload. At this point, both files / a / b / file1.txt and / a / b / file2.txt in the same directory are successfully uploaded in FileZilla's high-concurrency scenario. File upload failures due to contention in the parent directory creation are eliminated.

[0104] As described above, the corresponding pseudo code is as follows:

[0105]

[0106] Through the description of the above implementation methods, those skilled in the art can clearly understand that the method according to the above embodiment can be implemented by means of software plus the necessary general hardware platform, and of course it can also be implemented by hardware, but in many cases the former is a better implementation method.

[0107] Figure 4 FIG. 1 is a schematic diagram showing the structure of an embodiment of a code retrieval device according to the present invention. Figure 4 As shown, the device includes:

[0108] The request acquisition module 410 is configured to receive multiple file upload requests initiated by the connected client based on the file transfer protocol;

[0109] A path identification module 420 is used to identify the file upload path of the file to be uploaded carried in each file upload request;

[0110] An information detection module 430 is used to detect missing information of directories at all levels in the file directory corresponding to each file upload path;

[0111] The directory completion module 440 is used to complete the file directory based on the missing information of the directories at all levels, and upload the corresponding files to be uploaded to the completed file directory.

[0112] In an optional implementation, the information detection module 430 includes:

[0113] The file upload submodule is used to upload the file to be uploaded in the file directory corresponding to the file upload path and obtain the file upload result;

[0114] The directory check submodule is used to check the missing information of each level of directory starting from the root directory corresponding to each file upload path if the file upload result is upload failure.

[0115] In an optional embodiment, the directory completion module 440 includes:

[0116] The submodule for generating the completed directory path is used to generate the corresponding completed directory path according to the missing information of the directories at all levels;

[0117] The completion file directory acquisition submodule is used to create missing directories step by step according to the completion directory path to obtain the completion file directory;

[0118] The first file uploading submodule is used to upload the file to be uploaded to the corresponding location under the completion file directory.

[0119] In an optional implementation, the directory completion module 440 further includes:

[0120] The file upload request comparison submodule is used to compare any current file upload request among multiple file upload requests with other file upload requests to obtain a request comparison result;

[0121] The file directory merging and completion submodule is used to merge and complete the file directory based on the missing information of the directories at all levels in the file directory corresponding to the current file upload request and the missing information of the directories at all levels in the file directory corresponding to the other file upload requests, if the request comparison result indicates that the file upload path corresponding to the current file upload request is repeated with the file upload path corresponding to other file upload requests, to obtain a merged and completed file directory;

[0122] The second file uploading submodule is used to upload the file to be uploaded corresponding to the current file upload request to the corresponding location under the merged and completed file directory.

[0123] In an optional embodiment, the file directory merging and completion submodule includes:

[0124] A missing directory identification unit, used to identify missing parts of directories at all levels in the file directories corresponding to the current file upload request and other file upload requests;

[0125] The directory merging and completion unit is used to integrate the identified missing information of directories at all levels, and merge and complete the file directory based on the integrated missing information.

[0126] In an optional implementation, the second to-be-uploaded file uploading submodule includes:

[0127] A space acquisition unit is used to obtain the available file storage space corresponding to the merged and completed file directory and the file required space of the file to be uploaded corresponding to the current file upload request;

[0128] A file uploading unit is used to upload the file to be uploaded to the corresponding location under the merged and completed file directory if the available file storage space is greater than or equal to the file required space;

[0129] The result feedback unit is used to generate insufficient storage space prompt information if the available file storage space is less than the file required space, and feedback it to the connected client to prompt the user to expand the storage space or delete some files to free up storage space.

[0130] In an optional implementation, the directory completion module 440 further includes:

[0131] The directory analysis submodule is used to analyze the missing information of directories at all levels to obtain the missing directory levels and corresponding directory names;

[0132] The refined storage submodule is used to store the missing directory levels and corresponding directory names obtained through analysis in the form of a list to obtain a missing directory information list;

[0133] The directory creation submodule is used to create missing directories step by step based on the missing directory information list until all missing directory levels are completed and the completed file directory is obtained;

[0134] The file upload submodule is used to create a storage file corresponding to the file to be uploaded based on the completed file directory, and upload the file content of the file to be uploaded to the storage file.

[0135] For the description of the features in the embodiment corresponding to the directory management device, please refer to the relevant description of the embodiment corresponding to the directory management method, and no further details will be given here.

[0136] The embodiment of the present application also provides an electronic device, such as Figure 5 As shown, it includes a memory 510 and a processor 520. The memory 510 stores a computer program, and the processor 520 is configured to run the computer program to execute the steps in any of the above directory management method embodiments.

[0137] An embodiment of the present application further provides a computer-readable storage medium, in which a computer program is stored. The computer program is configured to execute the steps of any one of the above directory management method embodiments when running.

[0138] In an exemplary embodiment, the computer-readable storage medium may include, but is not limited to, various media that can store computer programs, such as a USB flash drive, a read-only memory (ROM), a random access memory (RAM), a mobile hard disk, a magnetic disk, or an optical disk.

[0139] An embodiment of the present application further provides a computer program product, which includes a computer program. When the computer program is executed by a processor, the steps of any of the above directory management method embodiments are implemented.

[0140] An embodiment of the present application further provides another computer program product, including a non-volatile computer-readable storage medium, wherein the non-volatile computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps of any of the above-mentioned directory management method embodiments are implemented.

[0141] Professionals may further appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, computer software, or a combination of the two. In order to clearly illustrate the interchangeability of hardware and software, the above description has generally described the components and steps of each example according to their functions. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professionals and technicians may use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of this application.

[0142] The above is a detailed introduction to a directory management method, device, electronic device, and storage medium provided by the present application. Specific examples are used herein to illustrate the principles and implementation methods of the present application. The description of the above embodiments is only used to help understand the method and core ideas of the present application. It should be pointed out that for ordinary technicians in this technical field, without departing from the principles of the present application, several improvements and modifications can be made to the present application, and these improvements and modifications also fall within the scope of protection of the claims of the present application.

Claims

1. A directory management method, characterized in that: Applied to the server, including: Receive multiple file upload requests initiated by the connected client based on the file transfer protocol; Identify the file upload path of the file to be uploaded carried in each file upload request; Detect missing information of directories at all levels in the file directory corresponding to each file upload path; The file directory is completed based on the missing information of the directories at all levels, and the corresponding files to be uploaded are uploaded to the completed file directory.

2. The method according to claim 1, characterized in that The detecting missing information of directories at all levels in the file directory corresponding to each file upload path includes: Uploading the file to be uploaded in the file directory corresponding to the file upload path to obtain a file upload result; If the file upload result is upload failure, the directory at each level will be checked for missing information starting from the root directory corresponding to each file upload path.

3. The method according to claim 1, characterized in that The method of completing the file directory based on the missing information of the directories at all levels and uploading the corresponding files to be uploaded to the completed file directory includes: Generate the corresponding completed directory path based on the missing information of directories at all levels; Creating missing directories step by step according to the completion directory path to obtain a completion file directory; Upload the file to be uploaded to the corresponding location under the completed file directory.

4. The method according to claim 1, wherein The method further includes: completing the file directory based on the missing information of the directories at all levels, and uploading the corresponding files to be uploaded to the completed file directory; Compare any current file upload request among the multiple file upload requests with other file upload requests to obtain a request comparison result; If the request comparison result indicates that the file upload path corresponding to the current file upload request is duplicated with the file upload path corresponding to other file upload requests, then the file directories are merged and completed based on the missing information of the directories at all levels in the file directory corresponding to the current file upload request and the missing information of the directories at all levels in the file directory corresponding to the other file upload requests to obtain a merged and completed file directory; Upload the file to be uploaded corresponding to the current file upload request to the corresponding location under the merged and completed file directory.

5. The method according to claim 4, characterized in that The method of merging and completing the file directory based on missing information of directories at all levels in the file directory corresponding to the current file upload request and missing information of directories at all levels in the file directory corresponding to other file upload requests to obtain a merged and completed file directory includes: Identify missing parts of directories at all levels in the file directories corresponding to the current file upload request and other file upload requests; The identified missing information of directories at all levels is integrated, and the file directories are merged and completed based on the integrated missing information.

6. The method according to claim 4, characterized in that The step of uploading the file to be uploaded corresponding to the current file upload request to the corresponding location in the merged and completed file directory includes: Obtaining the available file storage space corresponding to the merged and completed file directory and the file space required for the file to be uploaded corresponding to the current file upload request; If the available file storage space is greater than or equal to the required file space, the file to be uploaded is uploaded to the corresponding location under the merged and completed file directory; If the available file storage space is less than the required file space, insufficient storage space prompt information is generated and fed back to the connected client to prompt the user to expand the storage space or delete some files to free up storage space.

7. The method according to claim 1, characterized in that The method further includes: completing the file directory based on the missing information of the directories at all levels, and uploading the corresponding files to be uploaded to the completed file directory; Analyze the missing information of directories at all levels to obtain the missing directory levels and corresponding directory names; The missing directory levels and corresponding directory names obtained by analysis are stored in a list form to obtain a missing directory information list; Based on the missing directory information list, creating missing directories level by level until all missing directory levels are completed, thereby obtaining a completed file directory; Based on the completed file directory, a storage file corresponding to the file to be uploaded is created, and the file content of the file to be uploaded is uploaded to the storage file.

8. A directory management device, characterized in that: include: The request acquisition module is used to receive multiple file upload requests initiated by the connected client based on the file transfer protocol; A path identification module is used to identify the file upload path of the file to be uploaded carried in each file upload request; An information detection module is used to detect missing information in directories at all levels in the file directory corresponding to each file upload path; The directory completion module is used to complete the file directory based on the missing information of the directories at all levels, and upload the corresponding files to be uploaded to the completed file directory.

9. An electronic device, characterized in that: include: memory for storing computer programs; A processor, configured to implement the steps of the directory management method according to any one of claims 1 to 7 when executing the computer program.

10. A computer-readable storage medium, characterized in that The computer-readable storage medium stores a computer program, wherein the computer program, when executed by a processor, implements the steps of the directory management method according to any one of claims 1 to 7.