Disclosure of Invention
The application aims to provide a file sharing method, which can solve the technical problem of improving the applicability of the file sharing method to a certain extent. The application also provides a file sharing device, equipment and a computer readable storage medium.
In order to achieve the above purpose, the present application provides the following technical solutions:
a file sharing method is applied to a server of a file sharing system and comprises the following steps:
determining a shared file in a shared directory;
creating a snapshot directory corresponding to the shared directory;
carrying out snapshot on the shared file to obtain a snapshot file;
storing the snapshot file into the snapshot directory;
and sending the corresponding relation between the sharing directory and the snapshot directory to a client of the file sharing system so that the client accesses the snapshot file based on the corresponding relation.
Preferably, the snapshot of the shared file to obtain a snapshot file includes:
and carrying out snapshot on the shared file within a preset time length after the snapshot directory is created to obtain the snapshot file.
Preferably, the snapshot of the shared file to obtain a snapshot file includes:
and judging whether a request for modifying the shared file exists, if so, carrying out snapshot on the shared file to obtain the snapshot file.
Preferably, the snapshot of the shared file to obtain a snapshot file includes:
and judging whether the server side is idle, if so, snapshotting the shared file to obtain the snapshot file.
Preferably, the snapshot of the shared file to obtain a snapshot file includes:
and judging whether the shared file is accessed, if not, carrying out snapshot on the shared file to obtain the snapshot file.
Preferably, after the creating the snapshot directory corresponding to the shared directory, the method further includes:
and setting the authority of the client to the snapshot directory as a read-only authority.
A file sharing method is applied to a client of a file sharing system and comprises the following steps:
receiving a corresponding relation between a shared directory and a snapshot directory sent by a server of the file sharing system, wherein the snapshot directory stores snapshot files of the shared files;
determining the shared directory in the server side, and determining the snapshot directory based on the corresponding relation;
determining and accessing the shared file in the shared directory;
and determining and accessing the snapshot file in the snapshot directory.
A file sharing device is applied to a server of a file sharing system and comprises:
the first determining module is used for determining shared files in the shared directory;
the first establishing module is used for establishing a snapshot directory corresponding to the shared directory;
the first snapshot module is used for carrying out snapshot on the shared file to obtain a snapshot file;
the first storage module is used for storing the snapshot file into the snapshot directory;
the first sending module is used for sending the corresponding relation between the shared directory and the snapshot directory to a client of the file sharing system so that the client can access the snapshot file based on the corresponding relation.
A file sharing apparatus comprising:
a memory for storing a computer program;
a processor for implementing the steps of the file sharing method as described in any one of the above when executing the computer program.
A computer-readable storage medium, in which a computer program is stored which, when being executed by a processor, carries out the steps of the file sharing method as set forth in any one of the preceding claims.
The file sharing method is applied to a server side of a file sharing system, and shared files are determined in a shared directory; creating a snapshot directory corresponding to the shared directory; carrying out snapshot on the shared file to obtain a snapshot file; storing the snapshot file into a snapshot directory; and sending the corresponding relation between the sharing directory and the snapshot directory to a client of the file sharing system so that the client accesses the snapshot file based on the corresponding relation. According to the method and the device, the shared file can be snapshot to obtain the snapshot file, the snapshot file is stored in the snapshot directories with different sharing targets, and the corresponding relation between the shared directories and the snapshot directories is sent to the client, so that the client can access the shared file and the snapshot file based on the corresponding relation, and the applicability is good. The file sharing device, the equipment and the computer readable storage medium provided by the application also solve the corresponding technical problems.
Detailed Description
The technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the drawings in the embodiments of the present application, and it is obvious that the described embodiments are only a part of the embodiments of the present application, and not all of the embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present application.
Referring to fig. 1, fig. 1 is a first flowchart of a file sharing method according to an embodiment of the present disclosure.
The file sharing method provided by the embodiment of the application is applied to a server of a file sharing system, and can comprise the following steps:
step S101: shared files are determined in a shared directory.
In practical applications, a server of the file sharing system may determine a shared file in a shared directory first, specifically, a file in the shared directory specified by a user may be determined as a shared file under the control of the user, and the like.
Step S102: a snapshot directory corresponding to the shared directory is created.
In practical application, when a shared file needs to be restored, a corresponding snapshot file needs to be generated, and the shared file is restored by means of the snapshot file.
In a specific application scenario, the snapshot directory may be created near the shared directory so as to quickly find the snapshot directory corresponding to the shared directory, and certainly, other ways may also be used to create the snapshot directory corresponding to the shared directory, which is not specifically limited herein.
Step S103: and carrying out snapshot on the shared file to obtain a snapshot file.
Step S104: and storing the snapshot file into a snapshot directory.
In practical application, after the snapshot directory corresponding to the shared directory is created, the shared file can be snapshot to obtain a corresponding snapshot file, and the snapshot file is stored in the snapshot directory, so that the corresponding snapshot file can be searched in the snapshot directory subsequently.
In a specific application scenario, the triggering condition for snapshot of the shared file may be determined according to actual needs, and the present application is not specifically limited herein.
Step S105: and sending the corresponding relation between the sharing directory and the snapshot directory to a client of the file sharing system so that the client accesses the snapshot file based on the corresponding relation.
In practical applications, after the snapshot file is stored in the snapshot directory, the correspondence between the shared directory and the snapshot directory may be sent to the client of the file sharing system, so that the client may access the snapshot file and the shared file based on the correspondence.
The file sharing method is applied to a server side of a file sharing system, and shared files are determined in a shared directory; creating a snapshot directory corresponding to the shared directory; carrying out snapshot on the shared file to obtain a snapshot file; storing the snapshot file into a snapshot directory; and sending the corresponding relation between the sharing directory and the snapshot directory to a client of the file sharing system so that the client accesses the snapshot file based on the corresponding relation. According to the method and the device, the shared file can be snapshot to obtain the snapshot file, the snapshot file is stored in the snapshot directories with different sharing targets, and the corresponding relation between the shared directories and the snapshot directories is sent to the client, so that the client can access the shared file and the snapshot file based on the corresponding relation, and the applicability is good.
In the file sharing method provided by the embodiment of the application, in the process of obtaining the snapshot file by snapshotting the shared file by the server of the file sharing system, the shared file can be snapshotted within a preset time length after the snapshot directory is created, so that the snapshot file is obtained.
Specifically, the preset time duration may be a short time duration, for example, the preset time duration may be 10s, so as to implement immediate backup of the shared file.
It should be noted that all operations accessing the share are blocked until the operations are completed, so this way of generating the snapshot file is suitable for application scenarios where there is substantially no shared access at a certain time.
In the file sharing method provided by the embodiment of the application, the server of the file sharing system can judge whether a request for modifying the shared file exists or not in the process of snapshotting the shared file to obtain the snapshot file, and if so, the shared file is snapshotted to obtain the snapshot file. That is, only when the shared file needs to be modified, in order to restore the shared file before modification, the shared file may be snapshot first to obtain a corresponding snapshot file, and after the snapshot file is obtained, the shared file may be modified in response to a request for modifying the shared file.
It should be noted that, this snapshot file generation method may affect the performance of writing, so that it is suitable for an application scenario that has low performance requirement and mainly uses a small file.
In the file sharing method provided by the embodiment of the application, the server of the file sharing system can judge whether the server is idle or not in the process of snapshotting the shared file to obtain the snapshot file, and if so, the server snapshotts the shared file to obtain the snapshot file.
That is, the shared file can be snapshot when the server is idle, and a corresponding snapshot file is obtained.
In the file sharing method provided by the embodiment of the application, the server of the file sharing system performs snapshot on the shared file to obtain the snapshot file, and whether the shared file is accessed or not can be judged, and if not, the shared file is subjected to snapshot to obtain the snapshot file.
That is, the shared file can be snapshot only when the server side does not have the shared file accessed, so as to obtain the corresponding snapshot file.
In the file sharing method provided by the embodiment of the application, after the server of the file sharing system creates the snapshot directory corresponding to the shared directory, in order to prevent a user from modifying the snapshot file maliciously, the permission of the client to the snapshot directory can be set as a read-only permission.
Referring to fig. 2, fig. 2 is a second flowchart of a file sharing method according to an embodiment of the present disclosure.
The file sharing method provided by the embodiment of the application is applied to a client of a file sharing system, and can comprise the following steps:
step S201: receiving a corresponding relation between a shared directory and a snapshot directory sent by a server of the file sharing system, wherein the snapshot directory stores snapshot files of the shared files.
Step S202: and determining a shared directory in the server side, and determining a snapshot directory based on the corresponding relation.
Step S203: shared files are determined and accessed in the shared directory.
Step S204: the snapshot files are determined and accessed in a snapshot directory.
The description of the corresponding steps in the file sharing method provided in the embodiment of the present application may refer to the foregoing embodiments, and is not repeated here.
Referring to fig. 3, fig. 3 is a first structural diagram of a file sharing apparatus according to an embodiment of the present disclosure.
The file sharing apparatus provided in an embodiment of the present application is applied to a server of a file sharing system, and may include:
a first determining module 101, configured to determine a shared file in a shared directory;
a first creating module 102, configured to create a snapshot directory corresponding to the shared directory;
the first snapshot module 103 is configured to snapshot a shared file to obtain a snapshot file;
the first storage module 104 is configured to store the snapshot file into a snapshot directory;
the first sending module 105 is configured to send the correspondence between the shared directory and the snapshot directory to a client of the file sharing system, so that the client accesses the snapshot file based on the correspondence.
The file sharing apparatus provided in an embodiment of the present application is applied to a server of a file sharing system, and the first snapshot module may include:
and the first snapshot unit is used for carrying out snapshot on the shared file within a preset time length after the snapshot directory is created to obtain the snapshot file.
The file sharing apparatus provided in an embodiment of the present application is applied to a server of a file sharing system, and the first snapshot module may include:
the first judging unit is used for judging whether a request for modifying the shared file exists, and if so, the shared file is snapshot to obtain a snapshot file.
The file sharing apparatus provided in an embodiment of the present application is applied to a server of a file sharing system, and the first snapshot module may include:
and the second judgment unit is used for judging whether the server side is idle or not, and if so, carrying out snapshot on the shared file to obtain a snapshot file.
The file sharing apparatus provided in an embodiment of the present application is applied to a server of a file sharing system, and the first snapshot module may include:
and the third judging unit is used for judging whether the shared file is accessed, and if not, carrying out snapshot on the shared file to obtain a snapshot file.
The file sharing apparatus provided in the embodiment of the present application is applied to a server of a file sharing system, and may further include:
and the first setting module is used for setting the permission of the client to the snapshot directory as the read-only permission after the first creating module creates the snapshot directory corresponding to the shared directory.
Referring to fig. 4, fig. 4 is a schematic diagram illustrating a second structure of a file sharing apparatus according to an embodiment of the present disclosure.
The file sharing apparatus provided in the embodiment of the present application is applied to a client of a file sharing system, and may include:
a first receiving module 201, configured to receive a correspondence between a shared directory and a snapshot directory sent by a server of a file sharing system, where a snapshot file of the shared file is stored in the snapshot directory;
a second determining module 202, configured to determine a shared directory in the server, and determine a snapshot directory based on the correspondence;
a third determining module 203, configured to determine and access a shared file in the shared directory;
a fourth determining module 204, configured to determine and access the snapshot file in the snapshot directory.
The application also provides file sharing equipment and a computer readable storage medium, which have corresponding effects of the file sharing method provided by the embodiment of the application. Referring to fig. 5, fig. 5 is a schematic structural diagram of a file sharing device according to an embodiment of the present disclosure.
The file sharing device provided by the embodiment of the application comprises a memory 201 and a processor 202, wherein a computer program is stored in the memory 201, and the processor 202 implements the following steps when executing the computer program:
determining a shared file in a shared directory;
creating a snapshot directory corresponding to the shared directory;
carrying out snapshot on the shared file to obtain a snapshot file;
storing the snapshot file into a snapshot directory;
and sending the corresponding relation between the sharing directory and the snapshot directory to a client of the file sharing system so that the client accesses the snapshot file based on the corresponding relation.
The file sharing device provided by the embodiment of the application comprises a memory 201 and a processor 202, wherein a computer program is stored in the memory 201, and the processor 202 implements the following steps when executing the computer program: and in a preset time length after the snapshot directory is created, carrying out snapshot on the shared file to obtain a snapshot file.
The file sharing device provided by the embodiment of the application comprises a memory 201 and a processor 202, wherein a computer program is stored in the memory 201, and the processor 202 implements the following steps when executing the computer program: and judging whether a request for modifying the shared file exists, and if so, carrying out snapshot on the shared file to obtain a snapshot file.
The file sharing device provided by the embodiment of the application comprises a memory 201 and a processor 202, wherein a computer program is stored in the memory 201, and the processor 202 implements the following steps when executing the computer program: and judging whether the server side is idle, and if so, snapshotting the shared file to obtain a snapshot file.
The file sharing device provided by the embodiment of the application comprises a memory 201 and a processor 202, wherein a computer program is stored in the memory 201, and the processor 202 implements the following steps when executing the computer program: and judging whether the shared file is accessed, if not, carrying out snapshot on the shared file to obtain a snapshot file.
The file sharing device provided by the embodiment of the application comprises a memory 201 and a processor 202, wherein a computer program is stored in the memory 201, and the processor 202 implements the following steps when executing the computer program: and after the snapshot directory corresponding to the shared directory is created, setting the permission of the client to the snapshot directory as a read-only permission.
The file sharing device provided by the embodiment of the application comprises a memory 201 and a processor 202, wherein a computer program is stored in the memory 201, and the processor 202 implements the following steps when executing the computer program:
receiving a corresponding relation between a shared directory and a snapshot directory sent by a server of a file sharing system, wherein the snapshot directory stores snapshot files of the shared files;
determining a shared directory in a server side, and determining a snapshot directory based on the corresponding relation;
determining a shared file in a shared directory and accessing the shared file;
the snapshot files are determined and accessed in a snapshot directory.
Referring to fig. 6, another file sharing device provided in the embodiment of the present application may further include: an input port 203 connected to the processor 202, for transmitting externally input commands to the processor 202; a display unit 204 connected to the processor 202, for displaying the processing result of the processor 202 to the outside; and the communication module 205 is connected with the processor 202 and is used for realizing the communication between the file sharing device and the outside world. The display unit 204 may be a display panel, a laser scanning display, or the like; the communication method adopted by the communication module 205 includes, but is not limited to, mobile high definition link technology (HML), Universal Serial Bus (USB), High Definition Multimedia Interface (HDMI), and wireless connection: wireless fidelity technology (WiFi), bluetooth communication technology, bluetooth low energy communication technology, ieee802.11s based communication technology.
A computer-readable storage medium is provided in an embodiment of the present application, in which a computer program is stored, and when the computer program is executed by a processor, the computer program implements the following steps:
determining a shared file in a shared directory;
creating a snapshot directory corresponding to the shared directory;
carrying out snapshot on the shared file to obtain a snapshot file;
storing the snapshot file into a snapshot directory;
and sending the corresponding relation between the sharing directory and the snapshot directory to a client of the file sharing system so that the client accesses the snapshot file based on the corresponding relation.
A computer-readable storage medium is provided in an embodiment of the present application, in which a computer program is stored, and when the computer program is executed by a processor, the computer program implements the following steps: and in a preset time length after the snapshot directory is created, carrying out snapshot on the shared file to obtain a snapshot file.
A computer-readable storage medium is provided in an embodiment of the present application, in which a computer program is stored, and when the computer program is executed by a processor, the computer program implements the following steps: and judging whether a request for modifying the shared file exists, and if so, carrying out snapshot on the shared file to obtain a snapshot file.
A computer-readable storage medium is provided in an embodiment of the present application, in which a computer program is stored, and when the computer program is executed by a processor, the computer program implements the following steps: and judging whether the server side is idle, and if so, snapshotting the shared file to obtain a snapshot file.
A computer-readable storage medium is provided in an embodiment of the present application, in which a computer program is stored, and when the computer program is executed by a processor, the computer program implements the following steps: and judging whether the shared file is accessed, if not, carrying out snapshot on the shared file to obtain a snapshot file.
A computer-readable storage medium is provided in an embodiment of the present application, in which a computer program is stored, and when the computer program is executed by a processor, the computer program implements the following steps: and after the snapshot directory corresponding to the shared directory is created, setting the permission of the client to the snapshot directory as a read-only permission.
A computer-readable storage medium is provided in an embodiment of the present application, in which a computer program is stored, and when the computer program is executed by a processor, the computer program implements the following steps:
receiving a corresponding relation between a shared directory and a snapshot directory sent by a server of a file sharing system, wherein the snapshot directory stores snapshot files of the shared files;
determining a shared directory in a server side, and determining a snapshot directory based on the corresponding relation;
determining a shared file in a shared directory and accessing the shared file;
the snapshot files are determined and accessed in a snapshot directory.
The computer-readable storage media to which this application relates include Random Access Memory (RAM), memory, Read Only Memory (ROM), electrically programmable ROM, electrically erasable programmable ROM, registers, hard disk, a removable disk, a CD-ROM, or any other form of storage media known in the art.
For a description of a relevant part in the file sharing apparatus, the device, and the computer readable storage medium provided in the embodiments of the present application, reference is made to detailed descriptions of a corresponding part in the file sharing method provided in the embodiments of the present application, and details are not repeated here. In addition, parts of the above technical solutions provided in the embodiments of the present application, which are consistent with the implementation principles of corresponding technical solutions in the prior art, are not described in detail so as to avoid redundant description.
It is further noted that, herein, relational terms such as first and second, and the like may be used solely to distinguish one entity or action from another entity or action without necessarily requiring or implying any actual such relationship or order between such entities or actions. Also, the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising an … …" does not exclude the presence of other identical elements in a process, method, article, or apparatus that comprises the element.
The previous description of the disclosed embodiments is provided to enable any person skilled in the art to make or use the present application. Various modifications to these embodiments will be readily apparent to those skilled in the art, and the generic principles defined herein may be applied to other embodiments without departing from the spirit or scope of the application. Thus, the present application is not intended to be limited to the embodiments shown herein but is to be accorded the widest scope consistent with the principles and novel features disclosed herein.