A cross-device file sharing method and system based on blockchain
Through the blockchain-based cross-device file sharing method, the complete traceability of data usage records in cross-device file sharing and data sharing of different file systems are solved, and unified file management and sharing is realized, and multiple operations are supported.
Patent Information
- Application Number
- CN202411786758.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-06
- Publication Date
- 2025-04-25
- Estimated Expiration
- 2044-12-06
AI Technical Summary
The prior art cannot effectively solve the problems of complete traceability of data usage records in cross-device file sharing and data sharing of different file systems.
Through the cross-device file sharing method based on blockchain, the blockchain main chain of the cross-device shared file directory is obtained, and a blockchain sub-chain is created for the actual directories inside each device, and a complete main chain is formed through the mount relationship to realize the unified management and sharing of file directories.
It realizes unified management and sharing of files between different devices, ensures complete traceability of data usage records, supports file addition, deletion, modification, and search operations, and adapts to abstract conversion of different file systems.
Smart Images

Figure CN119271642B_ABST
Abstract
Description
Technical Field
[0001] Embodiments of the present invention relate to the field of data sharing technology, and in particular, to a cross-device file sharing method and system based on blockchain. Background Art
[0002] With the current surge in demand for data sharing, a single machine can no longer handle the storage and management of massive files. The original Unix or Linux system is a stand-alone or distributed file system without records, which cannot meet the data sharing parties of different file systems' complete traceability function for data usage records.
[0003] Therefore, it is urgent to propose a cross-device file sharing method and system to integrate the file systems of multiple devices and use a unified behavior to solve the problem of complete traceability of data usage records. In the prior art, CN115378960A discloses a distributed fast file sharing method and system based on a new blockchain, and CN113360458B discloses a distributed file storage sharing system based on an alliance chain, but neither of them can solve this problem well. Summary of the invention
[0004] The embodiments of the present invention provide a cross-device file sharing method and system based on blockchain to solve the above technical problems.
[0005] In a first aspect, an embodiment of the present invention provides a cross-device file sharing method based on blockchain, comprising:
[0006] Obtaining a blockchain main chain for cross-device shared file directories, wherein the blockchain main chain includes the first blocks of top-level virtual directories at all levels, and each first block records the name of each virtual directory and the block information of the parent virtual directory;
[0007] In response to a file sharing request from at least one device, a second block is created for each level of actual directories within each device, wherein each second block records the name, storage device and path of each actual directory, as well as the block information of the parent actual directory, and all second blocks of the same device together constitute a blockchain sub-chain of the same device;
[0008] Add at least one first block to the blockchain main chain, and mount the blockchain sub-chains of each device to each newly added first block, so that each blockchain sub-chain with a mounting relationship and the blockchain main chain together constitute a complete main chain;
[0009] Generate a user-oriented cross-device shared file directory tree based on the complete main chain, wherein the directory tree uses the directories in each first block and the second block as nodes and maintains the hierarchical relationship between the directories;
[0010] In response to a user operation on any directory in the directory tree, locate the target block where the directory is located from the complete main chain; if the target block is a second block, access the corresponding actual directory according to the storage device and path in the target block; convert the user operation into an operation recognized by the storage device, execute and record the actual directory.
[0011] In a second aspect, an embodiment of the present invention provides a cross-device file sharing system based on blockchain, including:
[0012] A sub-chain layer, for responding to a file sharing request of at least one device, to create second blocks for each level of actual directories within each device, wherein each second block records the name, storage device and path of each actual directory, and block information of the parent actual directory, wherein all second blocks of the same device together constitute a blockchain sub-chain of the same device;
[0013] The logic integration layer is used to obtain the blockchain main chain of the cross-device shared file directory, wherein the blockchain main chain includes the first blocks of the top-level virtual directories, and each first block records the name of each virtual directory and the block information of the parent virtual directory; at least one first block is added to the blockchain main chain, and the blockchain sub-chains of each device are mounted under each newly added first block, and the blockchain sub-chains with mounting relationships and the blockchain main chain together constitute a complete main chain;
[0014] A view layer, for generating a user-oriented cross-device shared file directory tree based on the complete main chain, wherein the directory tree uses the directories in each first block and the second block as nodes and maintains the hierarchical relationship between the directories;
[0015] The logic integration layer is further used to: in response to a user operation on any directory in the directory tree, locate the target block where the any directory is located from the complete main chain; if the target block is a second block, access the corresponding actual directory according to the storage device and path recorded in the target block; convert the user operation into an operation recognized by the storage device, and execute it on the actual directory;
[0016] The chain layer is also used to record operations performed on each block directory.
[0017] In summary, this embodiment provides a cross-device file sharing method based on blockchain, which integrates and abstracts the sub-chains that record the file directories of each node to form a main chain, and then provides a joint and unified file management system to the outside world to achieve various basic tasks such as adding, deleting, modifying, and checking files. In this method, each device manages local file directories and files through its own sub-chain, and shares file directories with other devices through permission control; the main chain uniformly abstracts the file directory trees of each device's sub-chain to form a complete file directory tree system view to achieve the integration and sharing of multi-party directory trees; each device performs various operations on the directory tree through permission management, such as adding, deleting, modifying, and checking. In the above manner, the method can realize the abstract conversion of different file system formats; form a unified mount sharing of different file systems in a distributed manner; and achieve complete traceability and operation unification of data usage records through the cooperation of sub-chains and the main chain. BRIEF DESCRIPTION OF THE DRAWINGS
[0018] In order to more clearly illustrate the specific implementation methods of the present invention or the technical solutions in the prior art, the drawings required for use in the specific implementation methods or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are some implementation methods of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0019] Figure 1 is a schematic diagram of a cross-device file sharing system based on blockchain provided by an embodiment of the present invention;
[0020] Figure 2 It is a flowchart of a cross-device file sharing method based on blockchain provided by an embodiment of the present invention;
[0021] Figure 3 is a flowchart of another blockchain-based cross-device file sharing method provided by an embodiment of the present invention;
[0022] Figure 4 It is a schematic diagram of integrating the device sub-chain into the main chain provided by an embodiment of the present invention;
[0023] Figure 5 is a schematic diagram of a complete directory tree provided by an embodiment of the present invention;
[0024] Figure 6 is a schematic diagram of a first directory tree in a preview mode provided by an embodiment of the present invention;
[0025] Figure 7 It is a schematic diagram of generating a second directory tree level by level in a browsing operation provided by an embodiment of the present invention;
[0026] Figure 8is a schematic diagram of a second directory tree finally generated in a browsing provided by an embodiment of the present invention;
[0027] Fig. 9 is a schematic diagram of generating a second directory tree level by level in another browsing provided by an embodiment of the present invention;
[0028] Fig.10 is a schematic diagram of a second directory tree finally generated in another browsing provided by an embodiment of the present invention;
[0029] Fig.11 Schematic diagram of a second directory tree in a hybrid mode provided by an embodiment of the present invention. DETAILED DESCRIPTION
[0030] In order to make the purpose, technical solution and advantages of the present invention clearer, the technical solution of the present invention will be described clearly and completely below. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work belong to the scope of protection of the present invention.
[0031] In the description of the present invention, it should be noted that the terms "center", "upper", "lower", "left", "right", "vertical", "horizontal", "inner", "outer", etc., indicating the orientation or positional relationship, are based on the orientation or positional relationship shown in the drawings, and are only for the convenience of describing the present invention and simplifying the description, rather than indicating or implying that the device or element referred to must have a specific orientation, be constructed and operated in a specific orientation, and therefore cannot be understood as limiting the present invention. In addition, the terms "first", "second", and "third" are used for descriptive purposes only, and cannot be understood as indicating or implying relative importance.
[0032] In the description of the present invention, it is also necessary to explain that, unless otherwise clearly specified and limited, the terms "installed", "connected", and "connected" should be understood in a broad sense, for example, it can be a fixed connection, a detachable connection, or an integral connection; it can be a mechanical connection or an electrical connection; it can be a direct connection, or it can be indirectly connected through an intermediate medium, or it can be the internal communication of two components. For ordinary technicians in this field, the specific meanings of the above terms in the present invention can be understood according to specific circumstances.
[0033] An embodiment of the present invention provides a cross-device file sharing method based on blockchain. In order to illustrate the method, a cross-device file sharing system based on blockchain for implementing the method is first introduced. Figure 1This is a schematic diagram of a cross-device file sharing system based on blockchain provided by an embodiment of the present invention. The system forms a sub-chain directory tree by forming the files of each participant, and unifies the sub-chains into the main chain by mounting, thus forming a complete and unified file directory tree for the outside world. Figure 1 As shown, the system consists of four layers from bottom to top: the underlying chain layer, the logic integration layer, the permission control layer and the view layer.
[0034] Among them, the sub-chain layer is mainly responsible for the file tree directory integration of each node (i.e., the equipment of each sharing party). The integration needs to follow unified standard specifications. At the same time, it is responsible for various basic marking work of the sub-chain, such as addition, deletion, modification, and query.
[0035] The logical integration layer is mainly responsible for the abstract conversion of the file directory trees of each chain to form a virtual and complete directory tree main chain.
[0036] The permission control layer is mainly responsible for content filtering of commands at the top-level view operation layer.
[0037] The view layer is mainly responsible for displaying content to users.
[0038] Based on the above layers, each participating node forms its own file directory system according to unified standard specifications. This directory system is called sub-chain X. Each sub-chain needs to be added to the main chain through mounting operations, and various verification tasks such as permission control, ID allocation, and tagging are required during mounting. After mounting, each sub-chain forms a complete directory main chain through a unified abstract integration operation. The main chain displays a complete and unified file directory tree system to the outside world, thus forming a bottom-level distributed and top-level unified external file directory tree system.
[0039] Specifically, the chain layer forms a directory chain with the sub-node file directory system according to the specified standards, and executes the basic operations issued by the main chain; the logic integration layer performs mounting and abstract transformation. The main purpose of mounting is to combine the sub-chains to form a complete main chain within the organization, and filter the contents of the sub-chains at the same time, such as no longer displaying deleted files; the permission control layer implements the permission control of participating nodes and users, and can control the visibility and operability of the file directory tree for all parties; the view layer displays the main chain to the user in the form of a file directory tree, and receives various operations from the user.
[0040] Based on the above system, Figure 2 and Figure 3All of them are flow charts of a cross-device file sharing method based on blockchain provided by an embodiment of the present invention. The method can be executed by the above-mentioned cross-device file sharing system or other electronic devices, and is applicable to scenarios where file data is shared between multiple devices, such as traffic big data sharing scenarios. The sharing parties in this scenario may include highway management departments, traffic management departments, vehicle supervision departments, equipment manufacturers, etc., and the devices involved in sharing may include highway electromechanical equipment, vehicle-mounted equipment, or any computer or server storing relevant data. Figure 2 and Figure 3 The key links of this method, such as blockchain construction, directory tree display and operation conversion, are presented from different perspectives. Figure 2 and Figure 3 , the method specifically comprises the following steps:
[0041] S110. Obtain a blockchain main chain for a cross-device shared file directory, wherein the blockchain main chain includes the first blocks of top-level virtual directories at each level, and each first block records the name of each virtual directory and block information of a parent virtual directory.
[0042] S120. In response to a file sharing request from at least one device, create a second block for each level of actual directories within each device, wherein each second block records the name, storage device and path of each actual directory, as well as the block information of the parent actual directory. All second blocks of the same device together constitute a blockchain branch of the same device.
[0043] This embodiment integrates the shared files of different devices into the same file directory system through the blockchain structure. Each entry in the file directory system is called a directory. The directory can be a file or a folder. Each directory records specific directory information through a blockchain. Further, the directory in this embodiment includes two types, one is the top-level virtual directory, and the other is the directory that actually exists inside each device, also called the actual directory. The two types of directories use two types of blocks to record directory information, and the specific contents recorded are not exactly the same. Among them, the block of the top-level virtual directory records the block ID of the current virtual directory, the name of the current virtual directory, and the block ID of the parent virtual directory of the current virtual directory (i.e., the adjacent upper-level virtual directory); and the block of the actual directory records the block ID of the current actual directory, the name of the current actual directory, the storage device of the current actual directory and the storage path in the device, and the block ID of the parent actual directory (i.e., the adjacent upper-level actual directory). For the convenience of distinction and description, the block corresponding to the top-level virtual directory is referred to as the first block, and the block corresponding to the actual directory is referred to as the second block.
[0044] In S120, each participant node (ie, each device) converts the local file directory system using a unified standard to form a respective file node directory chain, such as Figure 3 The physical file systems of different nodes can be different, such as Figure 3 The file systems of nodes A and B are inconsistent, so a unified conversion standard is needed, including chain formation specifications, block content format specifications, etc. In a specific implementation, the specific conversion method may include the following steps:
[0045] Step 1: Read the file directory system format of node X, find and analyze its link structure, and record the basic meta information of each file block, wherein the basic meta information includes the storage device and path of the file.
[0046] Step 2: Convert each basic meta-information in the file directory of the underlying physical structure into a block in a unified format, and indicate its parent block information to form a bidirectional linked list-like tree relationship so that the block can be quickly found. Note that the block here only saves the file directory tree relationship information, and does not save the real file. Exemplarily, the information in the block can be simplified as follows: the Y file is in the D disk File folder of the X node, its type is a folder or file, and its size is GB (windows system), or the Y file is mounted in the D directory of the X device, and its type is a directory or file (linux system). The specific expression can be changed according to the file management system in different operating systems, but the goal is to express different underlying file management systems into a bidirectional linked tree relationship with a blockchain structure through conversion operations. In addition, the bidirectional linked tree relationship with a blockchain structure is only accumulated, and no branch changes are made to achieve permanent traceability of the historical content of the file.
[0047] S130. Add at least one first block to the blockchain main chain, and mount the blockchain sub-chains of each device to each newly added first block, so that the blockchain sub-chains that have a mounting relationship and the blockchain main chain together constitute a complete main chain.
[0048] In this step, each sharing device realizes the mounting operation of the sub-chain through logical integration, corresponding to Figure 3 In "2-Mount", this operation is mainly to add the sub-chain to the main chain. The mounting work mainly involves logical integration, permission allocation, identity authentication, etc.; logical integration involves the integration of sub-node directory content, and the operation integration and conversion of sub-node directory trees. Here we mainly explain the integration of sub-node directory content.
[0049] Specifically, the integration of directory contents mainly realizes the directory unification function of different nodes. In this embodiment, a first block is added to the main chain, and the block directory file system of node X is mounted to the first block. Figure 4The process of integrating node sub-chains into the main chain is shown in Figure 1. After mounting, accessing A-1-1 in the main chain is equivalent to accessing node A sub-directory area M.
[0050] Optionally, for any device and any newly added first block, the name of the device can be used as the name of the virtual directory in the first block; then, the second block at the head end of the blockchain branch of the device is located, and the ID of the first block is used as the block ID of the parent actual directory in the second block at the head end, so that the mounting operation of the branch can be completed.
[0051] S140. Generate a user-oriented cross-device shared file directory tree based on the complete main chain, wherein the directory tree uses the directories in each of the first block and the second block as nodes and maintains the hierarchical relationship between the directories.
[0052] The above S110-S130 generates a shared file directory relationship across devices through the blockchain structure. This step generates a user-oriented directory tree based on the directory relationship. The directory tree can provide users with an intuitive directory view through a tree structure, including displaying a complete directory tree or displaying subdirectories of the current directory based on the directory tree. The directory tree can shield the differences between devices and display all shared devices as the same file system. Figure 3 This part corresponds to "3-Display". The permission management layer is required to manage the permissions of the complete main chain. The main purpose is to filter different operations based on different permissions and display them through the view layer; the main purpose is to distribute the rationality of operations downward.
[0053] Optionally, a complete directory tree for cross-device shared files can be generated and displayed based on the complete main chain. The complete directory tree uses the directories corresponding to all the first blocks and second blocks in the complete main chain as nodes, and each node corresponds to a directory (i.e., a block). Figure 5 A complete directory tree is shown as an example. In actual applications, the depth and volume of the complete directory tree are much larger than this example. In addition, it should be noted that the nodes in the above steps S110-S130 and the subsequent step S150 refer to blockchain nodes (i.e., a certain device), while the nodes in this step S140 refer to tree nodes in the directory tree (i.e., a certain directory). They should be distinguished when understanding.
[0054] The complete directory tree can include all directories, making it easy for users to understand all the file information involved in the sharing and its hierarchical structure in the entire shared file system. When a user wants to access a directory, he needs to start from the root node in the directory tree (such as the top folder displayed to the user), and open the sub-directories at each level layer by layer until he sees the directory he wants to access; correspondingly, when a user does not have access rights to a directory, the user does not have access rights to the sub-directories at all levels under the directory. Therefore, in the case of a large number of devices and a large directory system, the complete directory tree inevitably has the problem of too deep levels and too many nodes without access rights, which is not conducive to users quickly finding files with access rights. In response to this problem, this embodiment provides a specific implementation method, according to different directory modes and user permissions, the nodes and their connection relationships in the complete directory tree are changed to form directory trees for different users in different directory modes.
[0055] Among them, the directory mode refers to a directory display method that can be selected by the user. This embodiment sets different directory modes, aiming to display a directory tree that is easy to find to the user according to the focus of the user, including displaying a complete directory tree or displaying subdirectories of the current directory according to the directory tree. Optionally, three directory modes can be provided by investigating user needs: preview mode, browse mode and mixed mode. The focus and directory tree of each directory mode are different. For the convenience of distinction and description, this embodiment refers to the directory trees in the above three modes as the first directory tree, the second directory tree and the third directory tree respectively. The focus of the three modes and the directory tree generation method are specifically described below.
[0056] The first is the preview mode. This mode focuses on the user's understanding of the complete data system. It will completely restore the directories to which the user has access rights and their hierarchical positions in the complete directory tree to the user, but will not display the directories to which the user has no access rights, in order to reduce the size of the directory tree and facilitate users to quickly find useful information. Figure 5 Take the complete directory tree in as an example, where the solid line represents the directory node to which the current user has access rights, and the dotted line represents the directory node to which the current user does not have access rights. If the user selects the preview mode, the system will automatically generate the following Figure 6 The first directory tree shown. Based on this directory tree, when the user clicks directory b1, the view layer will only display directory c1, and directory c2 and its subdirectories (if any) will not be displayed. Since the file access permissions of different users are not exactly the same, the first directory trees of different users are also not exactly the same.
[0057] The second is browsing mode. This mode focuses on the user's browsing process, and reflects the user's focus on file data through the user's browsing process. Optionally, in browsing mode, the directories to which the current user has access rights are further subdivided into directories with full access rights (the current user has access rights to all levels of subdirectories under the directory), and directories with partial access rights (the current user only has access rights to some subdirectories under the directory), and the subdirectories here include adjacent subdirectories (also called subdirectories) and adjacent subdirectories (such as subdirectories of subdirectories); and according to each user's browsing process and the directories with full access rights, the nodes and their connection relationships in the first directory tree are changed, and the second directory tree for each browsing is generated respectively.
[0058] In a specific implementation, each continuous browsing process of the current user starting from the root node of the first directory tree can be regarded as one browsing. For example, if the cross-device file sharing system of this embodiment provides a unified login interface for users, a series of browsing processes after the user enters the user password to log in to the system can be regarded as one browsing. If the current user selects the browsing mode, the following operations are performed for each browsing of the user:
[0059] S2-1, create an empty second directory tree, add the root node of the first directory tree as the root node of the second directory tree browsed this time, and display the root node to the user as the current directory. Figure 6 Taking the first directory tree shown as an example, the current user first sees the root directory a during this browsing, and the root directory a is the current directory.
[0060] S2-2. In response to the current user's opening operation on the current directory, extract each path from the current directory to the directory with full access rights encountered for the first time from the first directory tree, and determine the node depth of each directory with full access rights encountered for the first time in each path; add the directory with full access rights with the smallest depth and the directories with the same depth in other paths as subdirectories of the current directory in the second directory tree.
[0061] Still Figure 6 Take the first directory tree in the figure as an example. The solid circle in the figure represents the directory to which the current user has partial access rights, and the solid rectangle represents the directory to which the current user has full access rights. Figure 6Extract the paths from a to the first encounter of a directory with full access rights, and finally extract 4 paths, namely path 1 (a—>b1—>c1), path 2 (a—>b2—>c3—>d3), path 3 (a—>b2—>c3—>d4—>e1), and path 4 (a—>b2—>c4—>d5—>e3); then, determine that c1 has a node depth of 3 in path 1, d3 has a node depth of 4 in path 2, e1 has a node depth of 5 in path 3, and e3 has a node depth of 5 in path 4. The directory with the smallest depth among c1, d3, e1, and e3 is c1. Finally, add c1 and the directory c3 with a depth of 3 in paths 2 and 3, and the directory c4 with a depth of 3 in path 4 to the second directory tree as subdirectories of a, so as to obtain Figure 7 The second directory tree is shown.
[0062] S2-3, displaying each added subdirectory as each new current directory, and returning to S2-2 according to each new current directory, in response to the current user's opening operation on a new current directory, extracting each new path from the new current directory to the first encountered new directory with full access rights from the first directory tree, and determining the new node depth of each new directory with full access rights encountered for the first time in each new path; adding the new directory with full access rights with the smallest depth and the directories with the same depth in other new paths as subdirectories of the new current directory in the second directory tree, and displaying each added subdirectory as each updated current directory, and returning to S2-2 according to each updated current directory..., and repeating this cycle until the browsing ends. In this process, if the current directory in a certain cycle is visited multiple times, there is no need to repeat the above operation for the directory, and the subdirectory generated in the previous cycle can be used to display it.
[0063] by Figure 7 Taking the second directory tree shown in FIG. 1 as an example, after S2-2, c1, c3 and c4 are displayed as three new current directories, and then return to S2-2. If the current user accesses the new current directory c1, Figure 6 Extract the new paths from c1 to the first encounter of the new directory with full access rights in the first directory tree, which are path 5 (c1->d1) and path 6 (c1->d2), and determine the depth of d1 in path 5 is 2, and the depth of d2 in path 6 is 2; select one of d1 and d2 with the smallest depth (assuming d1 is selected), add d1 and node d2 with a depth of 2 in path 6 to the second directory tree as subdirectories of c1 and display them to the user, and get Figure 8At the same time, the newly added d1 and d2 are used as new current directories. Assuming that the user opens d1 and ends the browsing, then Figure 8 This is the final second directory tree of this browsing, and so on and so forth until this browsing ends. From the above process, it can be seen that the second directory tree of a single browsing continues to extend downwards as the browsing process progresses. The final second directory tree reflects the user's browsing path this time, and can also reflect the user's attention route for shared files. Optionally, at the end of each browsing, the second directory tree of this browsing can be displayed to the user in a complete tree structure, and the user is prompted whether to keep the current file viewing directory and use it in subsequent file retrieval (such as the hybrid mode to be introduced later).
[0064] based on Figure 7 The second directory tree shown in the above example illustrates the situation where the current user opens a new current directory c1. If in another browsing, the user Figure 7 A new current directory c3 is opened under the second directory tree shown in Figure 6 Extract the new paths from c3 to the first encountered directory with full access rights in the first directory tree, including path 6 (c3->d3) and path 7 (c3->d4->e1), and determine that d3 has a depth of 2 in path 6 and e1 has a depth of 3 in path 7. Then add the directory d3 with the smallest depth and the directory d4 with a depth of 2 in path 7 to the second directory tree as subdirectories of c3. Fig. 9 Then, the subdirectories d3 and d4 are displayed to the user as updated current directories, and the process returns to S2-2. In response to the user's opening operation of d4, the above operation is repeated again to update the second directory tree to Fig.10 As shown in the figure, assuming that the user ends the browsing after opening d1, then Fig.10 It is the final second directory tree of this browsing. From the above two examples, it can be seen that the paths browsed by the same user each time are not exactly the same, and the second directory trees formed are also not exactly the same.
[0065] In summary, the second directory tree focuses on retaining directories to which users have full access rights. The files in such directories are usually content that is truly meaningful to users. Compared with such directories, directories with partial access rights are mainly used to summarize and classify directories with full access rights, so as to reflect the file hierarchy or facilitate classification and search when the number of directories is large. They do not directly include the content that users want to access. In the scenario of cross-device file sharing in this embodiment, due to the huge number of files covered by the entire file sharing system, the above-mentioned directories with partial access rights that are mainly used for summary classification will be more than the general file system. Therefore, the first directory tree still has the problem of too deep directory hierarchy and too many branches for a single user. The second directory tree omits some intermediate-level directories, while reducing the directory depth, retains the superior-subordinate relationship of each directory with full access rights in the file system to avoid disrupting the basic file hierarchy.
[0066] Furthermore, in the process of extending the second directory tree downward, if the number of subdirectories of a current directory is too large due to the omission of intermediate directories, exceeding a set threshold (e.g., 20), the parent directories of these 20 subdirectories in the first directory tree can be extracted and added to the second directory tree as subdirectories of the current directory, thereby avoiding too many directories at the same level in the second directory tree and increasing the file search burden of the user. The parent directory refers to the adjacent upper-level directory.
[0067] The third mode is the hybrid mode. This mode is a combination of the preview mode and the browse mode, focusing on the user's historical browsing process. By integrating and displaying the user's browsing paths in multiple browsings, it reflects the user's focus on the entire file system. Optionally, in the hybrid mode, the nodes and their connection relationships in the second directory tree that have been browsed multiple times can be changed according to the directory hierarchy in the first directory tree to generate a third directory tree in the hybrid mode.
[0068] In a specific implementation, if the current user selects the hybrid mode, or switches from other directory modes to the hybrid mode during the browsing process, first, a new empty third directory tree is created for the hybrid mode, and the root node of the first directory tree is added as the root node of the third directory tree; then, the path from the root node to each terminal leaf node of each second directory tree is extracted from the first directory tree; finally, the following operations are performed on each path respectively: if there is no intermediate node with the same depth as the terminal leaf node in other paths in the path, the terminal leaf node in the path is added to the third directory tree; if there is an intermediate node with the same depth as the terminal leaf node in other paths in the path, the terminal leaf node and the intermediate node in the path are added to the third directory tree; during the adding process, the superior-subordinate relationship between the root node and the added node is kept unchanged. Furthermore, in response to the current user's opening operation on a terminal leaf node in the third directory tree, the method of generating a subdirectory in the browsing mode can be used to perform operations S2-2 to S2-3 with a terminal leaf node as the current directory, and the third directory tree is continuously extended downward.
[0069] by Figure 8 and Fig.10 As an example, when the user currently selects the mixed mode, the system already stores Figure 8 and Fig.10 Two second directory trees, first Figure 6 The root node of the first directory tree is added as the root node of the third directory tree; then, determine Figure 8 The terminal leaf nodes d1, d2, c3 and c4 of the second directory tree, and Fig.10 The terminal leaf nodes c1, d3, e1 and c4 of the second directory tree, and from Figure 6 In the first directory tree, extract:
[0070] Path 8 from the root node a to the terminal leaf node d1 (a—>b1—>c1—>d1),
[0071] Path 9 from the root node a to the terminal leaf node d2 (a—>b1—>c1—>d2),
[0072] Path 10 from the root node a to the terminal leaf node c3 (a—>b2—>c3),
[0073] Path 11 from the root node a to the terminal leaf node c4 (a—>b2—>c4),
[0074] Path 12 from the root node a to the terminal leaf node c1 (a—>b1—>c1),
[0075] Path 13 from the root node a to the terminal leaf node d3 (a—>b2—>c3—>d3),
[0076] Path 14 from the root node a to the terminal leaf node e1 (a—>b2—>c3—>d4—>e1),
[0077] Path 15 from node a to the terminal leaf node c4 (a->b2->c4).
[0078] Finally, for each path, the terminal leaf node and the intermediate node (if any) in the path are added to the third directory tree. If the node to be added is already in the third directory tree, there is no need to add it again. Exemplarily, for path 8, there is an intermediate node c1 with the same depth as c3 in path 10, c4 in path 11, c1 in path 12, and c4 in path 15 (all depths are 3), then c1 and d1 are both added to the third directory tree, and the superior-subordinate relationship of a, c1, and d1 is kept unchanged; for path 14, there is an intermediate node c3 with the same depth as c3 in path 10, c4 in path 11, c1 in path 12, and c4 in path 15 (all depths are 3), and there is an intermediate node d4 with the same depth as d1 in path 8, d2 in path 9, and d3 in path 13 (all depths are 4), then c3, d4, and e1 are all added to the third directory tree, and the superior-subordinate relationship of a, c3, d4, and e1 is kept unchanged; the remaining paths 9, 10, 11, and 13 are similar, and the final third directory tree is as follows: Fig.11 When the user opens directory c4 according to the third directory tree, the method for generating subdirectories in the browsing mode (S2-2 to S2-3) can be used to display the subdirectories of c4 to the user and continuously extend the third directory tree.
[0079] In summary, for each user, the first directory tree ( Figure 6 ) includes all directories that the user has access rights to, so that the user can preview the complete file system within the scope of the permission; the second directory tree ( Figure 8 , Fig.10 ) includes directories with full access permissions that the user has visited in a single browsing, as well as directories with partial access permissions that are essential to reflecting the hierarchical relationship between these directories. This type of directory tree gradually extends downward with each browsing process of the user, quickly and conveniently displaying the files that the user wants to access with the minimum volume required for this browsing; and the third directory tree ( Fig.11 ) includes all directories with full access permissions that the user has visited multiple times, as well as directories with partial access permissions that are essential for reflecting the hierarchical relationship between these directories. This directory tree can restore the necessary hierarchical relationship of multiple second directory trees in the first directory tree, reflecting the file system accumulated by the user in the entire shared file system. Under this file system, the user can find the required files more comprehensively and quickly.
[0080] Furthermore, the above S110-S140 illustrate the mounting and directory display operations between the sub-chain and the main chain. In addition to mounting, each sub-chain can also be deleted from the main chain, thereby realizing the dynamic change of the cross-device shared file directory. Optionally, in response to a stop sharing request from at least one device, the mounting relationship between the blockchain sub-chain of each device and the first block is deleted, and the remaining blockchain main chain with a mounting relationship and each blockchain sub-chain together constitute a complete main chain; according to the new blockchain, the user-oriented cross-device shared file directory tree is updated.
[0081] S150. In response to a user operation on any directory in the directory tree, locate a target block where the any directory is located from the complete main chain, access the any directory according to the target block and execute the user operation.
[0082] In this step, the user operates the directories in the directory tree through the view layer, such as adding, deleting, modifying, and checking. This operation is a hierarchical operation, and the operation of the main chain needs to drill down layer by layer until the local file system of each node, and finally form a complete file directory operation. Optionally, depending on the directory mode, the directory tree can be a complete directory tree, a first directory tree, a second directory tree, or a third directory tree.
[0083] Optionally, the user operation may be performed in different ways depending on the target block. Specifically, if the target block is the first block, a corresponding operation is performed on any directory according to the definition of the user operation in the cross-device file sharing system. For example, when the user operation "double-click" is defined as an open operation in the file sharing system, any directory is directly opened.
[0084] If the target block is the second block, then access the corresponding actual directory according to the storage device and path in the target block; convert the user operation into an operation recognized by the storage device, execute and record it on the actual directory. Optionally, first identify the function of the user operation; then, according to the operating environment of the storage device, determine another operation in the file management system of the storage device for realizing the function, execute the other operation on the actual directory; and record the function as an operation record in the second block of the actual directory.
[0085] Combination Figure 3 In a specific implementation, the user sends an operation command through the front-end user interface, such as clicking a command to delete the File1 file in node A. Figure 3 After receiving the command, the system first searches for the file to be deleted in the complete main chain and locates it in the file directory branch chain of node A, as shown in Figure 3Then, the file directory chain information of node A is integrated to determine the specific location of node A where file File1 is located, and the file deletion API in the file management system on the node A machine is called to delete it. This API is related to the specific operating system, so different calls need to be made according to different physical machine file systems. For example, although some Windows and Linux file deletion operations both implement the POSIX standard, their underlying implementations are different, such as Figure 3 As shown in "7-Operation" in the figure. After the execution is completed, the block records the "delete" operation on the file.
[0086] In summary, this embodiment provides a cross-device file sharing method based on blockchain, which integrates and abstracts the sub-chains that record the file directories of each node to form a main chain, and then provides a joint and unified file management system to the outside world to achieve various basic tasks such as adding, deleting, modifying, and checking files. In this method, each device manages local file directories and files through its own sub-chain, and shares file directories with other devices through permission control; the main chain uniformly abstracts the file directory trees of each device's sub-chain to form a complete file directory tree system view to achieve the integration and sharing of multi-party directory trees; each device performs various operations on the directory tree through permission management, such as adding, deleting, modifying, and checking. In the above manner, the method can realize the abstract conversion of different file system formats; form a unified mount sharing of different file systems in a distributed manner; and achieve complete traceability and operation unification of data usage records through the cooperation of sub-chains and the main chain.
[0087] In addition, this embodiment can provide different directory trees for different users according to the users' file access permissions; for the same user, it can form directory trees of different sizes according to different directory modes to meet the users' different needs for directory emphasis; thereby helping users to quickly obtain useful files in the huge cross-device file sharing system and form their own file system, truly realizing accurate differentiated file services.
[0088] Based on the same inventive concept, this embodiment also provides a cross-device file sharing system based on blockchain. Figure 1 As shown, the sub-chain layer in the system is used to respond to a file sharing request from at least one device, and to create second blocks for each level of actual directories within each device, wherein each second block records the name, storage device and path of each actual directory, as well as the block information of the parent actual directory, wherein all second blocks of the same device together constitute a blockchain sub-chain of the same device.
[0089] The logical integration layer is used to obtain the blockchain main chain of the cross-device shared file directory, wherein the blockchain main chain includes the first blocks of the top-level virtual directories, and each first block records the name of each virtual directory and the block information of the parent virtual directory; at least one first block is added to the blockchain main chain, and the blockchain sub-chain of each device is mounted to each newly added first block, and the blockchain sub-chains with a mounting relationship and the blockchain main chain together constitute a complete main chain.
[0090] The view layer is used to generate a user-oriented cross-device shared file directory tree based on the complete main chain, wherein the directory tree uses the directories in each first block and the second block as nodes and maintains the hierarchical relationship between the directories.
[0091] The logical integration layer is also used to respond to user operations on any directory in the directory tree, locate the target block where the any directory is located from the complete main chain; if the target block is a second block, access the corresponding actual directory according to the storage device and path recorded in the target block; convert the user operation into an operation recognized by the storage device, and execute it on the actual directory.
[0092] The chain layer is also used to record operations performed on each block directory.
[0093] It should be noted that this embodiment and any of the above method embodiments are based on the same inventive concept, and the limitations in any of the above method embodiments are applicable to this embodiment and can achieve the same technical effects, which will not be repeated here.
[0094] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit it. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or replace some or all of the technical features therein by equivalents. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the technical solutions of the embodiments of the present invention.
Claims
1. A cross-device file sharing method based on blockchain, characterized in that: include: Obtaining a blockchain main chain for cross-device shared file directories, wherein the blockchain main chain includes the first blocks of top-level virtual directories at all levels, and each first block records the name of each virtual directory and the block information of the parent virtual directory; In response to a file sharing request from at least one device, a second block is created for each level of actual directories within each device, wherein each second block records the name, storage device and path of each actual directory, as well as the block information of the parent actual directory, and all second blocks of the same device together constitute a blockchain sub-chain of the same device; Add at least one first block to the blockchain main chain, and mount the blockchain sub-chains of each device to each newly added first block, so that each blockchain sub-chain with a mounting relationship and the blockchain main chain together constitute a complete main chain; Generate a user-oriented cross-device shared file directory tree based on the complete main chain, wherein the directory tree uses the directories in each first block and the second block as nodes and maintains the hierarchical relationship between the directories; In response to a user operation on any directory in the directory tree, locate the target block where the directory is located from the complete main chain; if the target block is a second block, access the corresponding actual directory according to the storage device and path in the target block; convert the user operation into an operation recognized by the storage device, execute and record the actual directory.
2. The method according to claim 1, characterized in that Also includes: In response to a stop sharing request from at least one device, the mounting relationship between the blockchain sub-chain of each device and the first block is deleted, and the remaining blockchain sub-chains with the mounting relationship and the blockchain main chain together form a complete new main chain; According to the complete new main chain, the user-oriented cross-device shared file directory tree is updated.
3. The method according to claim 1, characterized in that The step of mounting the blockchain sub-chains of each device to each newly added first block includes: Using the name of any device as the name of any virtual directory in the newly added first block; Locating a second block at the head end of a blockchain branch of any of the devices; The ID of any newly added first block is used as the block ID of the parent actual directory in the second block located at the head end.
4. The method according to claim 1, characterized in that: The step of generating a user-oriented cross-device shared file directory tree based on the complete main chain includes: Generate a complete directory tree for cross-device shared files based on the complete main chain, where the complete directory tree covers all directories in the complete main chain; According to different directory modes and user permissions, the nodes in the complete directory tree and their connection relationships are changed to form directory trees for different users in different directory modes.
5. The method according to claim 4, characterized in that The directory modes include preview mode, browse mode and mixed mode; The method of changing the nodes and their connection relationships in the complete directory tree according to different directory modes and user permissions to form directory trees for different users in different directory modes respectively includes: Perform the following operations for each user: S1. Hide the directory nodes without access rights in the complete directory tree to obtain a first directory tree in a preview mode; S2. In browsing mode, according to the browsing process and the directory with full access rights, the nodes and their connection relationships in the first directory tree are changed to generate a second directory tree for each browsing, wherein the directory with full access rights means that the current user has access rights to all subordinate directories under the directory; S3. In the hybrid mode, according to the directory hierarchy in the first directory tree, the nodes and their connection relationships in the second directory tree browsed multiple times are changed to generate a third directory tree in the hybrid mode.
6. The method according to claim 5, characterized in that The step of changing the nodes and connection relationships in the first directory tree according to the browsing process and the directory with full access rights to generate the second directory tree for each browsing comprises: Each continuous browsing process of the current user starting from the root node of the first directory tree is regarded as a browsing, and the following operations are performed for each browsing: S2-1, adding the root node as the root node of the second directory tree browsed this time, and displaying the root node as the current directory; S2-2, in response to the current user's opening operation on the current directory, extracting from the first directory tree each path from the current directory to the directory with full access rights encountered for the first time, and determining the node depth of each directory with full access rights encountered for the first time in each path; adding the directory with full access rights with the smallest depth and the directories with the same depth in other paths as subdirectories of the current directory in the second directory tree; S2-3, displaying each added subdirectory as a new current directory, and returning to S2-2 according to each new current directory until the current browsing is completed.
7. The method according to claim 6, characterized in that The step of adding the directory with the smallest depth and full access rights and the directories with the same depth in other paths as subdirectories of the current directory in the second directory tree includes: If the total number of the directory with full access rights at the smallest depth and the directories with the same depth in other paths is less than a set threshold, the directory with full access rights at the smallest depth and the directories with the same depth in other paths are added as subdirectories of the current directory in the second directory tree; If the total number of directories with the smallest depth and full access permissions and directories with the same depth in other paths is greater than or equal to a set threshold, the parent directory of the directory with the smallest depth and full access permissions in the first directory tree and directories with the same depth as the parent directory in other paths are added as subdirectories of the current directory in the second directory tree.
8. The method according to claim 5, characterized in that The step of changing the nodes and connection relationships in the second directory tree browsed multiple times and generating a third directory tree in a mixed mode according to the directory hierarchy in the first directory tree includes: Add the root node of the first directory tree as the root node of the third directory tree; Extracting, from the first directory tree, paths from the root node to each terminal leaf node of each second directory tree; Each terminal leaf node and the intermediate nodes in each path with the same depth as the terminal leaf nodes in other paths are added to the third directory tree, and the hierarchical relationship between the root node and each added node is kept unchanged during the adding process.
9. The method according to claim 1, characterized in that: The converting the user operation into an operation recognized by the storage device, executing and recording the actual directory, comprises: Identify the function of the user operation; Determine another operation in the file management system of the storage device for implementing the function according to the operating environment of the storage device, and perform the another operation on the actual directory; The function is added as an operation record into the second block of the actual directory.
10. A cross-device file sharing system based on blockchain, characterized in that: include: A sub-chain layer, for responding to a file sharing request of at least one device, to create second blocks for each level of actual directories within each device, wherein each second block records the name, storage device and path of each actual directory, and block information of the parent actual directory, wherein all second blocks of the same device together constitute a blockchain sub-chain of the same device; The logic integration layer is used to obtain the blockchain main chain of the cross-device shared file directory, wherein the blockchain main chain includes the first blocks of the top-level virtual directories, and each first block records the name of each virtual directory and the block information of the parent virtual directory; at least one first block is added to the blockchain main chain, and the blockchain sub-chains of each device are mounted under each newly added first block, and the blockchain sub-chains with mounting relationships and the blockchain main chain together constitute a complete main chain; A view layer, for generating a user-oriented cross-device shared file directory tree based on the complete main chain, wherein the directory tree uses the directories in each first block and the second block as nodes and maintains the hierarchical relationship between the directories; The logic integration layer is further used to: in response to a user operation on any directory in the directory tree, locate the target block where the any directory is located from the complete main chain; if the target block is a second block, access the corresponding actual directory according to the storage device and path recorded in the target block; convert the user operation into an operation recognized by the storage device, and execute it on the actual directory; The chain layer is also used to record operations performed on each block directory.
Citation Information
Patent Citations
File sharing method of cross-end equipment and related products
CN114356872A
Private cloud file guarantee method based on block chain, storage medium and terminal
CN115665177A