CN111782594A - File storage method and device - Google Patents

File storage method and device Download PDF

Info

Publication number
CN111782594A
CN111782594A CN202010633970.0A CN202010633970A CN111782594A CN 111782594 A CN111782594 A CN 111782594A CN 202010633970 A CN202010633970 A CN 202010633970A CN 111782594 A CN111782594 A CN 111782594A
Authority
CN
China
Prior art keywords
file
target
storage space
name
client device
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202010633970.0A
Other languages
Chinese (zh)
Inventor
龙奕志
方鸿灏
郑锋
许泉泉
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Hunan Happly Sunshine Interactive Entertainment Media Co Ltd
Original Assignee
Hunan Happly Sunshine Interactive Entertainment Media Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Hunan Happly Sunshine Interactive Entertainment Media Co Ltd filed Critical Hunan Happly Sunshine Interactive Entertainment Media Co Ltd
Priority to CN202010633970.0A priority Critical patent/CN111782594A/en
Publication of CN111782594A publication Critical patent/CN111782594A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/10File systems; File servers
    • G06F16/13File access structures, e.g. distributed indices
    • G06F16/137Hash-based
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/10File systems; File servers
    • G06F16/16File or folder operations, e.g. details of user interfaces specifically adapted to file systems
    • G06F16/164File meta data generation

Abstract

The invention discloses a file storage method and a device, which can determine a target storage space of a target file to be stored, determine whether a duplicate file with the same file name as the target file exists in the target storage space, if so, judge whether a file content algorithm value of the duplicate file is the same as a file content algorithm value of the target file, wherein the file content algorithm value is related to the file content of the file, if so, the duplicate file or the target file is stored in the target storage space, and if not, the file name of the target file and/or the file name of the duplicate file is modified, so that the file names of the target file and the duplicate file are different, and the target file with the different file name from the duplicate file is stored in the target storage space. The invention can avoid the loss of the file content in the target file, and can also improve the effective utilization rate of the data storage space in the target storage space while avoiding the loss of the file content.

Description

File storage method and device
Technical Field
The present invention relates to the field of file storage, and in particular, to a file storage method and apparatus.
Background
With the development of electronic information technology, the technology of file storage of terminal devices such as mobile phones and tablet computers is continuously improved. When a user uses a terminal device to download an object file, the prior art may store the downloaded object file in a certain folder inside the terminal device.
In the prior art, in the process of storing a target file in a folder, if a duplicate name file with the same file name as the target file is stored in the folder, the duplicate name file is overwritten by the target file, that is, the duplicate name file is deleted and only the target file is stored.
However, when the duplicate name file is overwritten by the target file, if the file content of the duplicate name file is different from the file content of the target file, the file content may be lost.
Disclosure of Invention
In view of the above problems, the present invention provides a file storage method and apparatus for overcoming the above problems or at least partially solving the above problems, and the technical solution is as follows:
a method of file storage, the method comprising:
determining a target storage space of a target file to be stored;
determining whether a duplicate name file with the same file name as the target file exists in the target storage space, if so, judging whether a file content algorithm value of the duplicate name file is the same as a file content algorithm value of the target file, wherein the file content algorithm value is related to the file content of the file;
if the duplicate name file is the same as the duplicate name file, saving the duplicate name file or the target file in the target storage space;
and if not, modifying the file name of the target file and/or the file name of the duplicate name file to enable the target file and the duplicate name file to have a difference, and storing the target file having the difference with the file name of the duplicate name file into the target storage space.
Optionally, the method is applied to a client device, where the target storage space is a persistent storage space, and before determining the target storage space of the target file to be stored, the method further includes:
acquiring a download address of the target file issued by a server device in communication connection with the client device;
and downloading the target file from the download address to the memory of the client device.
Optionally, the method is applied to a client device, where the target storage space is a persistent storage space, and before determining the target storage space of the target file to be stored, the method further includes:
acquiring a download address of the target file, a file name of the target file and a file content algorithm value of the target file issued by a server device in communication connection with the client device;
the determining whether a duplicate name file with the same file name as the target file exists in the target storage space includes: determining whether a duplicate name file with the same file name as the target file exists in the target storage space according to the file name of the target file issued by the server side equipment;
the judging whether the file content algorithm value of the rename file is the same as the file content algorithm value of the target file comprises the following steps:
judging whether the file content algorithm value of the duplicate name file is the same as the file content algorithm value of the target file issued by the server device;
the saving the rename file or the target file in the target storage space includes:
downloading the target file from the download address of the target file and storing the target file in the target storage space to cover the rename file;
or discarding the download address of the target file to avoid downloading the target file from the download address of the target file, so that the rename file is continuously saved in the target storage space.
Optionally, the method is applied to a client device, where the target storage space is a persistent storage space, and before determining the target storage space of the target file to be stored, the method further includes:
acquiring a download address of the target file and a file name of the target file issued by a server device in communication connection with the client device;
the determining whether a duplicate name file with the same file name as the target file exists in the target storage space includes: determining whether a duplicate name file with the same file name as the target file exists in the target storage space according to the file name of the target file issued by the server side equipment;
the method further comprises the following steps: downloading the target file from the download address to a memory of the client device;
the judging whether the file content algorithm value of the rename file is the same as the file content algorithm value of the target file comprises the following steps:
judging whether the file content algorithm value of the duplicate name file is the same as the file content algorithm value of the target file in the memory;
the saving the rename file or the target file in the target storage space includes:
storing the target file in the memory of the client device to the target storage space to cover the rename file;
or deleting the target file in the memory of the client device to avoid the target file from being stored in the target storage space, so that the duplicate name file is continuously stored in the target storage space.
Optionally, the method further includes:
acquiring a file identifier of a target file issued by server equipment in communication connection with the client equipment;
obtaining a file storage path of the target file stored in the target storage space in the client device;
and correspondingly storing the file identification of the target file and the file storage path into a database of the client equipment.
Optionally, correspondingly storing the file identifier of the target file and the file storage path in the database of the client device includes:
correspondingly storing the file identifier of the target file, the file storage path and the file name of the target file stored in the target storage space into a database of the client device;
or correspondingly storing the file identifier of the target file, the file storage path and the file content algorithm value of the target file into a database of the client device;
or correspondingly storing the file identifier of the target file, the file storage path, the file name of the target file stored in the target storage space and the file content algorithm value of the target file into a database of the client device.
A file storage apparatus, the apparatus comprising: the device comprises a first determining unit, a second determining unit, an algorithm value judging unit, a file saving unit and a file storing unit, wherein:
the first determining unit is used for determining a target storage space of a target file to be stored;
the second determining unit is used for determining whether a duplicate name file with the same file name as the target file exists in the target storage space, and if so, the algorithm value judging unit is executed;
the algorithm value judging unit is used for judging whether the file content algorithm value of the rename file is the same as the file content algorithm value of the target file, wherein the file content algorithm value is related to the file content of the file, and if the file content algorithm value is the same as the file content algorithm value of the rename file, the file saving unit is executed; if not, executing the file storage unit;
the file saving unit is used for saving the duplicate name file or the target file in the target storage space;
the file storage unit is used for modifying the file name of the target file and/or the file name of the duplicate name file so that the target file and the duplicate name file have difference, and storing the target file which has difference with the file name of the duplicate name file into the target storage space.
Optionally, the apparatus is applied to a client device, and the target storage space is a persistent storage space, and the apparatus further includes: a first obtaining unit and a first downloading unit, wherein:
the first obtaining unit is configured to obtain, before the target storage space of the target file to be stored is determined, a download address of the target file issued by a server device in communication connection with the client device;
the first downloading unit is configured to download the target file from the downloading address to the memory of the client device.
Optionally, the apparatus is applied to a client device, and the target storage space is a persistent storage space, and the apparatus further includes: a second obtaining unit for obtaining the second data,
the second obtaining unit is configured to obtain, before the target storage space of the target file to be stored is determined, a download address of the target file, a file name of the target file, and a file content algorithm value of the target file, where the download address of the target file is issued by a server device in communication connection with the client device;
the second determining unit is specifically configured to:
determining whether a duplicate file with the same file name as the target file exists in the target storage space according to the file name of the target file issued by the server device, and if so, executing the algorithm value judgment unit;
the algorithm value judging unit is specifically configured to:
judging whether the file content algorithm value of the duplicate name file is the same as the file content algorithm value of the target file issued by the server device, wherein the file content algorithm value is related to the file content of the file, and if so, executing the file storage unit; if not, executing the file storage unit;
the file saving unit is specifically configured to:
downloading the target file from the download address of the target file and storing the target file in the target storage space to cover the rename file;
or discarding the download address of the target file to avoid downloading the target file from the download address of the target file, so that the rename file is continuously saved in the target storage space.
Optionally, the apparatus is applied to a client device, and the target storage space is a persistent storage space, and the apparatus further includes: a third obtaining unit and a second downloading unit;
the third obtaining unit is configured to:
before the target storage space of the target file to be stored is determined, acquiring a download address of the target file and a file name of the target file, wherein the download address is issued by a server device in communication connection with the client device;
the second determining unit is specifically configured to:
determining whether a duplicate file with the same file name as the target file exists in the target storage space according to the file name of the target file issued by the server device, and if so, executing the algorithm value judgment unit;
the second downloading unit is configured to:
downloading the target file from the download address to a memory of the client device;
the algorithm value judging unit is specifically configured to:
judging whether the file content algorithm value of the rename file is the same as the file content algorithm value of the target file in the memory, wherein the file content algorithm value is related to the file content of the file, and if so, executing the file storage unit; if not, executing the file storage unit;
the file saving unit is used for:
storing the target file in the memory of the client device to the target storage space to cover the rename file;
or deleting the target file in the memory of the client device to avoid the target file from being stored in the target storage space, so that the duplicate name file is continuously stored in the target storage space.
Optionally, the apparatus further comprises: a fourth obtaining unit, a fifth obtaining unit, and a path saving unit, wherein:
the fourth obtaining unit is configured to obtain a file identifier of a target file issued by a server device in communication connection with the client device;
the fifth obtaining unit is configured to obtain a file storage path of the target file stored in the target storage space in the client device;
and the path saving unit is used for correspondingly saving the file identifier of the target file and the file storage path to a database of the client device.
Optionally, the path saving unit is specifically configured to:
correspondingly storing the file identifier of the target file, the file storage path and the file name of the target file stored in the target storage space into a database of the client device;
or correspondingly storing the file identifier of the target file, the file storage path and the file content algorithm value of the target file into a database of the client device;
or, correspondingly storing the file identifier of the target file, the file storage path, the file name of the target file stored in the target storage space and the file content algorithm value of the target file into the database of the client device, the file storage method and the device provided by the present invention can determine the target storage space of the target file to be stored, determine whether a duplicate name file with the same file name as the target file exists in the target storage space, if so, determine whether the file content algorithm value of the duplicate name file is the same as the file content algorithm value of the target file, wherein the file content algorithm value is related to the file content of the file, if so, save the duplicate name file or the target file in the target storage space, if not, modify the file name of the target file and/or the file name of the duplicate name file, and storing the target file with the file name difference with the duplicate name file into the target storage space. The invention can only store one of the target file and the duplicate name file when the file contents of the target file and the duplicate name file are the same, and can improve the effective utilization rate of the data storage space in the target storage space while avoiding the loss of the file contents; and when the file contents of the target file and the rename file are different, modifying the file name of the target file and/or the rename file, and storing the target file into a target storage space after modification, so that the file contents in the target file are prevented from being lost.
The foregoing description is only an overview of the technical solutions of the present invention, and the embodiments of the present invention are described below in order to make the technical means of the present invention more clearly understood and to make the above and other objects, features, and advantages of the present invention more clearly understandable.
Drawings
In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings needed to be used in the description of the embodiments or the prior art will be briefly introduced below, it is obvious that the drawings in the following description are only embodiments of the present application, and for those skilled in the art, other drawings can be obtained according to the provided drawings without creative efforts.
FIG. 1 is a flow chart illustrating a file storage method according to an embodiment of the present invention;
FIG. 2 is a flow chart of another file storage method provided by the embodiment of the invention;
FIG. 3 is a flow chart of another file storage method provided by the embodiment of the invention;
FIG. 4 is a flow chart of another file storage method provided by the embodiment of the invention;
FIG. 5 is a flow chart of another file storage method provided by the embodiment of the invention;
FIG. 6 is a flow chart of another file storage method provided by the embodiment of the invention;
FIG. 7 is a flow chart of another file storage method provided by the embodiment of the invention;
FIG. 8 is a schematic structural diagram of a file storage apparatus according to an embodiment of the present invention;
FIG. 9 is a schematic structural diagram of another file storage device provided in an embodiment of the present invention;
FIG. 10 is a schematic structural diagram of another file storage device provided in an embodiment of the present invention;
FIG. 11 is a schematic structural diagram of another file storage device according to an embodiment of the present invention;
fig. 12 is a schematic structural diagram of another file storage device according to an embodiment of the present invention.
Detailed Description
Exemplary embodiments of the present invention will be described in more detail below with reference to the accompanying drawings. While exemplary embodiments of the invention are shown in the drawings, it should be understood that the invention can be embodied in various forms and should not be limited to the embodiments set forth herein. Rather, these embodiments are provided so that this disclosure will be thorough and complete, and will fully convey the scope of the invention to those skilled in the art.
As shown in fig. 1, the present embodiment provides a file storage method, which may include the following steps:
s10, determining a target storage space of a target file to be stored;
the target file may be a file to be obtained, or a file that has been obtained and is to be stored in the target storage space.
Specifically, the file transmission method used for obtaining the target file is not limited, for example, network downloading is performed, and the target file may be a file obtained through network downloading or a file to be obtained through network downloading; then, for example, in bluetooth transmission between different devices, the target file may be a file obtained through bluetooth transmission or a file to be obtained through bluetooth transmission; for another example, when a file in a different storage space of the same device moves, the target file may be a file to be moved.
It should be noted that the present invention is not limited to the file type of the target file, such as video, audio, picture or text.
Wherein the target storage space may be a data storage space in a folder. The folder may be a folder in a hardware memory, such as a folder in a usb disk, such as a folder in a magnetic disk; the folder may also be a folder in virtual storage, such as a folder in memory. Of course, the folder may also be a subfolder in a certain folder.
It is understood that the target storage space may be a physical storage space or a virtual storage space.
It should be further noted that the target storage space may be a data storage space dedicated to storing a set of files (e.g., a set of files belonging to the same application, such as a set of files of a certain file type, and further such as a set of files of a certain project, etc.) including the target file. Of course, the target storage space may not be a data storage space dedicated to storing a set of files containing the target file association.
The target storage space of the target file can be determined according to the file transmission mode of the target file. Specifically, for a target file obtained by a certain file transmission mode, the present invention may store the target file in a corresponding target storage space by using a default storage path corresponding to the file transmission mode. For example, when the target file is a file obtained through network downloading, that is, a network downloading file, the present invention may store the target file in the corresponding target storage space by using a default storage path of the network downloading file.
Of course, the present invention can also determine the target storage space of the target file according to the file attribute of the target file. For example: and if the target file is a file downloaded by a certain application program, the default storage folder of the file downloaded by the application program is the target storage space of the target file.
The target storage space of the target file may be designated by the user.
Specifically, the present invention can be applied to an entity storage having a physical storage space, such as a client device such as a mobile phone and a tablet computer, a server device such as a server, and a device such as a magnetic disk and a usb disk; the invention can also be applied to virtual storage with virtual storage space, such as a memory.
S20, determining whether a duplicate name file with the same file name as the target file exists in the target storage space, and if so, executing the step S30;
specifically, the present invention may determine whether there is a duplicate name file with the same file name as the target file in the target storage space before storing the target file in the target storage space.
Specifically, the present invention may determine whether there is a duplicate file with the same file name as the target file in the target storage space by comparing the file name of the target file with the file names of the files in the target storage space. For example, if the file a, the file B, and the file C are stored in the target storage space, the present invention may compare the file name of the target file with the file name of the file a, compare the file name of the target file with the file name of the file B, and compare the file name of the target file with the file name of the file C.
Specifically, when a file with a character string of a file name equal to that of a target file exists in the target storage space, the method and the device can determine that a duplicate-name file with the same file name as the target file exists in the target storage space.
It should be noted that, after determining the rename file with the file name the same as that of the target file in the target storage space, the present invention further needs to compare the file contents of the target file and the rename file to determine whether to store the target file in the target storage space or how to store the target file in the target storage space.
It should be further noted that, if a file with a string of a file name equal to that of the target file does not exist in the target storage space, the present invention may determine that a rename file with a file name equal to that of the target file does not exist in the target storage space. At this time, the invention can directly save the target file into the target storage space without comparing the target file with each file in the target storage space about the file content.
S30, judging whether the file content algorithm value of the duplicate name file is the same as the file content algorithm value of the target file, wherein the file content algorithm value is related to the file content of the file, if so, executing the step S40; otherwise, go to step S41;
the file content algorithm value may be an algorithm value obtained by calculating the file content through an encryption algorithm. It should be noted that, when the same encryption algorithm is used for calculation, the file content of the target file and the file content algorithm value of the target file may be in one-to-one correspondence.
The present invention is not limited to the type of the encryption algorithm, for example, the encryption algorithm may be a hash algorithm.
Specifically, the invention may use a Hash Algorithm, such as an MD5 Algorithm (MD5Message-DigestAlgorithm, MD5 information digest Algorithm), SHA-1 Algorithm (Secure Hash Algorithm 1), etc., to calculate the corresponding file content Algorithm value according to the file content of the file.
Specifically, when the file content algorithm value of the rename file is the same as the file content algorithm value of the target file, the file content of the two files can be determined to be the same; when the file content algorithm value of the rename file is different from the file content algorithm value of the target file, the method and the device can determine that the file contents of the two files are different.
S40, storing the duplicate name file or the target file in the target storage space;
specifically, when the file content algorithm value of the duplicate name file is the same as the file content algorithm value of the target file, the method and the device can determine that the file names and the file contents of the duplicate name file and the target file are the same and belong to the same file.
It can be understood that, because the duplicate name file and the target file belong to the same file, the invention can only reserve one of the duplicate name file and the target file in the target storage space, so as to reduce the consumption of the data storage space in the target storage space while avoiding the loss of the file content and improve the effective utilization rate of the target storage space.
Alternatively, when the rename file is saved to the target storage space, step S40 of the present invention may be configured to abandon the saving of the target file to the target storage space, for example, to discard or delete the target file.
S41, modifying the file name of the target file and/or the file name of the duplicate name file to make the file name of the target file different from that of the duplicate name file, and storing the target file different from that of the duplicate name file in the target storage space.
Specifically, when the file content algorithm value of the rename file is different from the file content algorithm value of the target file, the method and the device can determine that the file content of the rename file is different from the file content of the target file. At this time, in order to avoid the loss of the file contents of the target file and the rename file caused by the coverage of the rename file by the target file when the target file is stored in the target storage space, the file name of the target file and/or the file name of the rename file can be modified, so that the target file is stored in the target storage space after the file names of the target file and/or the rename file are different.
In practical application, when modifying the file name of the target file and/or the file name of the duplicate name file, the invention may add different characters at the tail of the file name on the basis of keeping the file name of the duplicate name, for example, according to the sequence of the storage time, add characters for identifying the version number at the tail of the file name, if the file names of the duplicate name file and the duplicate name of the target file are both "three-in-one file", the invention may modify the file name of the duplicate name file into "three-in-one file (1)", modify the file name of the target file into "three-in-one file (2)", or, modify the file name of the duplicate name file into "three-in-one file (1)", and then modify the file name of the target file into "three-in-one file (1)". Therefore, when searching for files, a user can quickly identify and find the needed files, the service time of the equipment used by the user for searching the needed files is reduced, and the calculation amount of the equipment is reduced.
It can be understood that, when modifying the file name and/or the rename file of the target file, the invention can modify the file name of only one of the two files, and this way can reduce the calculation amount of the device compared with the way of modifying the file names of both files.
Of course, the invention can also adopt a mode of only modifying the file name of the target file but not modifying the file name of the duplicate name file, and the mode can reduce the use time of the equipment and the calculation amount of the equipment, and simultaneously can be convenient for a user to identify the duplicate name file according to the originally memorized file name of the duplicate name file, thereby avoiding the situation that the user is confused in identifying the duplicate name file after the file name is modified by the duplicate name file.
It should be noted that, when modifying the file name and/or the rename file of the target file, the present invention needs to avoid modifying the file name of the target file and the file rename in the target storage space, and also needs to avoid modifying the rename file of the file name and other file renames in the target storage space.
The file storage method provided in this embodiment may determine a target storage space of a target file to be stored, determine whether a duplicate name file having a file name identical to that of the target file exists in the target storage space, if so, judging whether the file content algorithm value of the rename file is the same as the file content algorithm value of the target file, wherein the file content algorithm value is related to the file content of the file, if the file content algorithm value is the same as the file content algorithm value, the duplicate name file or the target file is saved in the target storage space, if not, modifying the file name of the target file and/or the file name of the rename file, and storing the target file with the file name difference with the duplicate name file into the target storage space. The method can only store one of the target file and the duplicate name file when the file contents of the target file and the duplicate name file are the same, and can improve the effective utilization rate of the data storage space in the target storage space while avoiding the loss of the file contents; and when the file contents of the target file and the rename file are different, modifying the file name of the target file and/or the rename file, and storing the target file into a target storage space after modification, so that the file contents in the target file are prevented from being lost.
Based on the steps shown in fig. 1, the present embodiment proposes another file storage method, as shown in fig. 2, the method may be applied to a client device, the target storage space may be a persistent storage space, and before step S10, the method may further include the following steps:
s100, acquiring a download address of the target file issued by a server device in communication connection with the client device;
the client device may include a mobile phone, a tablet computer, a desktop computer, and the like, and the specific device type of the client device is not limited in the present invention.
The persistent storage space is a data storage space of a disk, a U disk and the like which can persistently store files. It should be noted that, in the client device, as opposed to the target storage space in which the file can be persistently stored, the memory of the client device can only temporarily store the file, and when power is off or shutdown occurs, the file or data stored in the memory of the client device may be lost.
Specifically, the target storage space may be a certain data storage space in the client device.
The server device is a device capable of performing data transmission with the client device, such as a mobile phone, a tablet computer, a server, and the like. Specifically, the communication connection between the server device and the client device may be a bluetooth connection, a wireless network connection, a network cable connection, and the like, which is not limited in the present invention.
The target file may be a file obtained through network downloading.
The present invention is not limited to specific types of the download address of the target file, for example, the download address of the target file may be a network file address based on the HTTP protocol in the network, or may be a P2P download address.
It should be understood that the location of the download address of the target file may be the server device, the client device itself, or other devices, which is not limited in the present invention.
S200, downloading the target file from the download address to a memory of the client device.
It should be noted that, before step S10 is executed, that is, the target file is downloaded from the download address to the memory of the client device, the present invention can effectively avoid that the client device cannot obtain the target file due to the expiration of the download address, or that the target file is modified or deleted in the time of waiting for the download of the client device.
It should be noted that, the reason why the present invention downloads the target file from the download address to the memory of the client device instead of downloading the target file to the other data storage space of the client device before executing step S10 is that the processing speed of the client device in data processing of the file in the memory is higher than the processing speed of the client device in data processing of the file in the other data storage space. Therefore, the target file is downloaded to the memory of the client device, and the processing speed can be higher when the target file in the memory is subjected to data processing in the subsequent process (for example, the target file in the memory is stored in the target storage space).
Specifically, after the target file is downloaded to the memory of the client device, the present invention may further execute the scheme formed by steps S10, S20, S30, S40, and S41, so as to save the target file from the memory of the client device to the target storage space in which the file can be persistently stored on the premise of avoiding the file content loss in the target storage space. Of course, if the target storage space stores a duplicate file having the same file name and file content as the target file, the present invention may not store the target file in the target storage space.
It should be further noted that, after the target file is stored in the target storage space from the memory of the client device, the target file in the memory of the client device may be deleted, and the memory of the client device may be released in time, so as to improve the processing efficiency of the client device.
When the file storage method provided by this embodiment is applied to the client device, the target file is downloaded from the download address of the target file to the memory of the client device in advance for temporary storage, so that the client device can obtain the target file in time, and the client device can have a faster operation speed when performing data processing on the target file in the memory subsequently.
Based on the steps shown in fig. 1, this embodiment proposes another file storage method, as shown in fig. 3, the method may be applied to a client device, the target storage space may be a persistent storage space, and before step S10, the method may further include:
s110, acquiring a download address of the target file, a file name of the target file and a file content algorithm value of the target file issued by a server device in communication connection with the client device;
specifically, the server device issues the download address of the target file, the file name of the target file, and the file content algorithm value of the target file to the client device before the client device downloads the target file.
When the download address, the file name and the file content algorithm value of the target file are issued, the issuing sequence of the download address, the file name and the file content algorithm value of the target file is not limited, for example, the download address of the target file can be issued first, then the file name of the target file is issued, and finally the file content algorithm value of the target file is issued. Of course, the present invention can also issue the three simultaneously.
It can be understood that, after receiving the file name of the target file and the file content algorithm value of the target file issued by the server device, the client device may compare the file name of the target file with the file names of the files in the target storage in advance according to the file name of the target file issued by the server device and compare the file content algorithm value of the target file with the file content algorithm value of the renamed file according to the file content algorithm value of the target file issued by the server device in the client device even if the client device does not download the target file.
Specifically, before the client device does not download the target file, the method and the device can determine whether the target storage space has a file with the same file name and the same file content algorithm value as those of the target file.
If the target file is not downloaded by the client device, that is, the file with the same file name and the same file content algorithm value as the target file exists in the target storage space, the target file does not need to be downloaded to the client device, so that resource consumption generated in the process of downloading the target file by the client device is reduced.
In this method, step S20 may specifically be:
determining whether a duplicate file with the same file name as the target file exists in the target storage space according to the file name of the target file issued by the server device, and if so, executing step S30;
it should be further noted that, the present invention may compare the file name of the target file with the file names of the files in the target storage space before the client device downloads the target file, that is, according to the file name of the target file issued by the server device, and the client device does not need to execute the process of extracting the file name from the target file after downloading the target file, so that the client device may avoid resource consumption caused by extracting the file name from the target file, and reduce the computation amount of the client device.
In this method, step S30 may specifically be:
judging whether the file content algorithm value of the duplicate name file is the same as the file content algorithm value of the target file issued by the server device, wherein the file content algorithm value is related to the file content of the file, and if so, executing the step S40; otherwise, go to step S41;
it should be further noted that, the present invention may compare the file content algorithm value of the target file with the file content algorithm value of the duplicate name file in the client device before the client device downloads the target file, that is, according to the file content algorithm value of the target file issued by the server device, without the client device executing the calculation process of the file content algorithm value of the target file after downloading the target file, so that the client device may avoid resource consumption caused by calculating the file content algorithm value of the target file, and reduce the computation load of the client device.
In this method, step S40 may specifically be:
downloading the target file from the download address of the target file and storing the target file in the target storage space to cover the rename file;
or discarding the download address of the target file to avoid downloading the target file from the download address of the target file, so that the rename file is continuously saved in the target storage space.
It should be noted that, if it is determined that the file with the same file name and file content algorithm value as the target file is stored in the target storage space before the client device downloads the target file, the target file may be directly downloaded to the target storage space of the client device to cover the renamed file according to the download address of the target file issued by the server device.
Of course, if the file with the same file name and the same file content algorithm value as the target file is determined to be stored in the target storage space before the target file is downloaded by the client device, the target file can be prevented from being downloaded to the client device by discarding the download address of the target file sent by the server device. At this time, the rename file with the same file name and file content as the target file can be continuously stored in the target storage space, so that the loss of the file content is avoided, and meanwhile, the resource consumption caused by downloading the target file by the client device can also be avoided.
Specifically, in the present invention, when step S41 is executed, since the target file is not downloaded to the client device, the present invention may modify only the filename of the rename file, so that the filenames of the target file and the rename file are different.
According to the file storage method provided by the embodiment, before the client device downloads the target file, whether the target storage space stores the file with the same file name and the same file content algorithm value as the target file is determined, and whether the target file needs to be downloaded to the target storage space is further determined, so that the client device does not need to download the target file when the target storage space stores the file with the same file name and the same file content algorithm value as the target file, and resource consumption caused by downloading the target file by the client device is avoided.
Based on the steps shown in fig. 1, this embodiment proposes another file storage method, as shown in fig. 4, the method may be applied to a client device, the target storage space may be a persistent storage space, and before step S10, the method may further include:
s120, acquiring a download address of the target file and a file name of the target file issued by a server device in communication connection with the client device;
it should be noted that, in order to avoid resource consumption caused by the server device calculating the file content algorithm value and reduce the dependence of the client device on the server device, the present invention may only issue the download address of the target file and the file name of the target file from the server device to the client device before the client device downloads the target file, and the file content algorithm value of the target file may be obtained by the client device calculating the file content of the target file after downloading the target file.
In this method, step S20 may specifically be:
determining whether a duplicate file with the same file name as the target file exists in the target storage space according to the file name of the target file issued by the server device, and if so, executing step S30;
in the method, step S21 may be further included:
downloading the target file from the download address to a memory of the client device;
it should be noted that, no matter what the determination result of the step S20 is, the present invention can execute the step S21.
If the determination result in the step S20 is that a duplicate file with the same file name as the target file exists in the target storage space, the present invention needs to execute the step S21, that is, the target file may be downloaded from the download address to the memory of the client device, so as to calculate the file content algorithm value of the target file, and determine the comparison between the file content algorithm value of the duplicate file and the file content algorithm value of the target file in the memory of the client device.
If the determination result in the step S20 is that there is no duplicate file with the same file name as the target file in the target storage space, the present invention needs to execute the step S21, that is, the target file can be downloaded from the download address to the memory of the client device, and then the target file in the memory of the client device is saved in the target storage space.
It should be noted that, the sequence of the steps S20 and S21 is not limited in the present invention.
Optionally, the present invention may execute step S21 (as shown in fig. 4) before step S20, that is, before comparing the file name of the target file with the file names of the files in the target storage space, the target file is downloaded to the memory of the client device.
Optionally, the present invention may also execute step S21 after step S20, that is, after determining whether a duplicate file with the same file name as the target file exists in the target storage space, downloading the target file to the memory of the client device.
In this method, step S30 may specifically be:
judging whether the file content algorithm value of the rename file is the same as the file content algorithm value of the target file in the memory, wherein the file content algorithm value is related to the file content of the file, and if so, executing a step S40; otherwise, go to step S41;
specifically, the method and the device can calculate the file content algorithm value of the target file in the client device after the client device downloads the target file so as to compare the file content algorithm value of the target file with the file content algorithm value of the rename file.
It should be noted that, after the client device downloads the target file, the file content algorithm value of the target file is obtained by calculating the file content algorithm value of the target file in the client device, so that the server device is not needed to calculate the file content algorithm value, the resource consumption of the server device is reduced, and the dependence of the client device on the server device is reduced.
In this method, step S40 may specifically be:
storing the target file in the memory of the client device to the target storage space to cover the rename file;
or deleting the target file in the memory of the client device to avoid the target file from being stored in the target storage space, so that the duplicate name file is continuously stored in the target storage space.
When the file storage method provided by the embodiment is applied to the client device, the file content algorithm value of the target file is obtained by calculating the file content algorithm value of the target file in the client device, so that the resource consumption of the server device can be reduced, and the dependence of the client device on the server device can be reduced.
Based on the steps shown in fig. 2, this embodiment proposes another file storage method, as shown in fig. 5, the method may further include the following steps:
s50, acquiring a file identifier of a target file issued by a server device in communication connection with the client device;
it should be noted that the client device may download the target file with the same file name through the server device for multiple times. Therefore, in order to accurately count the related information (such as the number of times of downloading a certain target file) of all target files downloaded by the client device through the server device and avoid uncertainty in the process of counting the duplicate name files, the method and the device can uniquely identify the target files.
The file identification of the target file can be the only identification of the target file, and the invention can uniquely determine the target file according to the file identification of the target file.
The file identifier of the target file may be one or more of numbers, letters, punctuation marks and other characters, which is not limited in the present invention.
It can be understood that the present invention can obtain the download address of the target file and the file identifier of the target file issued by the server device at the same time, that is, the server device can issue the download address of the target file and the file identifier of the target file to the client device at the same time.
Specifically, the present invention may also execute step S50 (as shown in fig. 5) after step S100, or execute step S50 before step S100. Of course, the present invention can also execute steps S100 and S50 at the same time.
It should be noted that the file identifiers of the target files obtained from the server device each time in the present invention may be different, so as to accurately count all the target files downloaded by the client device through the server device. Even if the target files downloaded by the server device are the same, the file identifications of the target files obtained from the server device can be different. For example, when the server device downloads the first target file for the first time, the file identifier of the target file obtained from the server device is "0001", and when the server device downloads the first target file again, the file identifier of the target file obtained from the server device is "0002".
S60, obtaining a file storage path of the target file stored in the target storage space in the client device;
it should be noted that, after the target file is stored in the target storage space, the file storage path of the target file stored in the target storage space in the client device may be obtained.
Alternatively, if the step S40 is executed and the saving of the target file in the target storage space is executed in step S40, the step S60 may be executed after step S40;
alternatively, if the present invention executes step S41, step S60 (shown in fig. 5) may be executed after step S41.
S70, correspondingly saving the file identification of the target file and the file storage path to a database of the client device.
Specifically, the present invention may establish a data table corresponding to the target storage space in a database of the client device, and after the target file is stored in the target storage space, correspondingly store the obtained file identifier of the target file and the file storage path of the target file in the data table corresponding to the target storage space.
Specifically, the present invention may store the file identifiers and the file storage paths of a plurality of target files stored in the target storage space in the same data table, for example, for a first target file, a second target file, and a third target file stored in the target storage space, the present invention may store the file identifier and the file storage path of the first target file in the first data table, store the file identifier and the file storage path of the second target file in the first data table, and store the file identifier and the file storage path of the third target file in the first data table.
It should be noted that, for the data table that can store the file identifier and the file storage address of the target file correspondingly, the present invention can use the data table as a file download directory for downloading the target file by the client device through the server device, so as to be displayed to the user. Therefore, when a user searches for a required target file in the client device, the file storage path of the corresponding target file can be searched in the data table in advance according to the file identifier of the target file, and the required target file can be quickly searched according to the searched file storage path, so that the searching efficiency of the user for the required target file is improved, and the resource consumption of the client device during working is reduced.
It is understood that the steps S50, S60, and S70 may also be applied to the file storage method shown in fig. 3 and the file storage method shown in fig. 4.
According to the file storage method provided by the embodiment, the file identification of the target file and the corresponding file storage address are stored in the data table of the database, so that the target file required by the user can be quickly searched, the searching efficiency of the user for the required target file is improved, and the resource consumption of the client device during working is reduced.
Based on the steps shown in fig. 5, this embodiment proposes another file storage method, and as shown in fig. 6, step S70 may specifically be:
and correspondingly storing the file identifier of the target file, the file storage path and the file name of the target file stored in the target storage space into a database of the client equipment.
It is understood that, when the target file is stored in the target storage space, the file name of the target file may be modified. Therefore, in order to ensure the accuracy of the file name of the recorded target file, the file name of the target file recorded in the database according to the present invention should be the file name of the target file already stored in the target storage space.
It should be noted that, the file name of the target file stored in the target storage space is recorded in the data table of the database, so that when the new target file to be stored is compared with the file names of the files in the target storage space, the file name of each file stored in the target storage space can be directly extracted from the data table of the database, and the extraction of each file is not required, thereby reducing the resource consumption of the client device.
According to the file storage method provided by the embodiment, the file name of the target file stored in the target storage space is recorded in the data table of the database, so that the resource consumption of the client device can be reduced.
Based on the steps shown in fig. 5, this embodiment proposes another file storage method, and as shown in fig. 7, step S70 may specifically be:
and correspondingly storing the file identifier of the target file, the file storage path and the file content algorithm value of the target file into a database of the client equipment.
It should be noted that, the file content algorithm value of the target file is in the data table of the database, and when the new target file to be stored is compared with the file content algorithm value of each file in the target storage space, the file content algorithm value of each file stored in the target storage space can be directly extracted from the data table of the database, and the calculation of the file content algorithm value of each file is not required, so that the resource consumption of the client device can be reduced.
Optionally, in another file storage method proposed in this embodiment, step S70 may specifically be:
and correspondingly storing the file identifier of the target file, the file storage path, the file name of the target file stored in the target storage space and the file content algorithm value of the target file into a database of the client device.
It can be understood that, the file name of the target file stored in the target storage space and the file content algorithm value of the target file are both recorded in the data table of the database, so that when the new target file to be stored is compared with each file in the target storage space by the file name and the file content algorithm value, the file name and the file content algorithm value of each file stored in the target storage space can be directly extracted from the data table of the database, and the resource consumption of the client device is further reduced.
According to the file storage method provided by the embodiment, the file content algorithm value of the target file is recorded in the data table of the database, so that the resource consumption of the client equipment can be reduced.
Corresponding to the steps shown in fig. 1, the present embodiment proposes a file storage apparatus, which may include, as shown in fig. 8: a first determining unit 100, a second determining unit 200, an algorithm value judging unit 300, a file saving unit 400, and a file storing unit 410, wherein:
the first determining unit 100 may be configured to determine a target storage space of a target file to be stored;
the target file may be a file to be obtained, or a file that has been obtained and is to be stored in the target storage space.
Wherein the target storage space may be a data storage space in a folder. It is understood that the target storage space may be a physical storage space or a virtual storage space.
The target storage space of the target file can be determined according to the file transmission mode of the target file. Specifically, for a target file obtained by a certain file transmission mode, the present invention may store the target file in a corresponding target storage space by using a default storage path corresponding to the file transmission mode.
Of course, the present invention can also determine the target storage space of the target file according to the file attribute of the target file. The target storage space of the target file may be designated by the user.
Specifically, the present invention can be applied to a physical memory having a physical memory space, and the present invention can also be applied to a virtual memory having a virtual memory space.
The second determining unit 200 may be configured to determine whether a duplicate file with a file name identical to that of the target file exists in the target storage space, and if so, execute the algorithm value determining unit 300;
specifically, the present invention may determine whether there is a duplicate name file with the same file name as the target file in the target storage space before storing the target file in the target storage space.
Specifically, the present invention may determine whether there is a duplicate file with the same file name as the target file in the target storage space by comparing the file name of the target file with the file names of the files in the target storage space.
Specifically, when a file with a character string of a file name equal to that of a target file exists in the target storage space, the method and the device can determine that a duplicate-name file with the same file name as the target file exists in the target storage space.
It should be noted that, after determining the rename file with the file name the same as that of the target file in the target storage space, the present invention further needs to compare the file contents of the target file and the rename file to determine whether to store the target file in the target storage space or how to store the target file in the target storage space.
It should be further noted that, if a file with a string of a file name equal to that of the target file does not exist in the target storage space, the present invention may determine that a rename file with a file name equal to that of the target file does not exist in the target storage space. At this time, the invention can directly save the target file into the target storage space without comparing the target file with each file in the target storage space about the file content.
The algorithm value determining unit 300 may be configured to determine whether a file content algorithm value of the renamed file is the same as a file content algorithm value of the target file, where the file content algorithm value is related to file content of a file, and if the file content algorithm value is the same as the file content algorithm value of the target file, the file saving unit 400 is executed; if not, executing the file storage unit 410;
the file content algorithm value may be an algorithm value obtained by calculating the file content through an encryption algorithm. It should be noted that, when the same encryption algorithm is used for calculation, the file content of the target file and the file content algorithm value of the target file may be in one-to-one correspondence.
The present invention is not limited to the type of encryption algorithm.
Specifically, when the file content algorithm value of the rename file is the same as the file content algorithm value of the target file, the file content of the two files can be determined to be the same; when the file content algorithm value of the rename file is different from the file content algorithm value of the target file, the method and the device can determine that the file contents of the two files are different.
The file saving unit 400 may be configured to save the rename file or the target file in the target storage space;
specifically, when the file content algorithm value of the duplicate name file is the same as the file content algorithm value of the target file, the method and the device can determine that the file names and the file contents of the duplicate name file and the target file are the same and belong to the same file.
It can be understood that, since the duplicate name file and the target file belong to the same file, the present invention can only reserve one of the duplicate name file and the target file in the target storage space.
Alternatively, when the rename file is saved in the target storage space, the file saving unit 400 may abandon the saving of the target file in the target storage space, for example, discard or delete the target file.
The file storage unit 410 may be configured to modify the file name of the target file and/or the file name of the duplicate name file, so that the target file and the duplicate name file have a difference in file name, and store the target file having a difference in file name from the duplicate name file into the target storage space.
Specifically, when the file content algorithm value of the rename file is different from the file content algorithm value of the target file, the method and the device can determine that the file content of the rename file is different from the file content of the target file. At this time, the invention can modify the file name of the target file and/or the file name of the rename file, so that the target file is stored in the target storage space after the file names of the target file and/or the rename file are different.
It should be noted that, when modifying the file name and/or the rename file of the target file, the present invention needs to avoid modifying the file name of the target file and the file rename in the target storage space, and also needs to avoid modifying the rename file of the file name and other file renames in the target storage space.
The file storage device provided by the embodiment can only store one of the target file and the duplicate name file when the file contents of the target file and the duplicate name file are the same, and can improve the effective utilization rate of the data storage space in the target storage space while avoiding the loss of the file contents; and when the file contents of the target file and the rename file are different, modifying the file name of the target file and/or the rename file, and storing the target file into a target storage space after modification, so that the file contents in the target file are prevented from being lost.
Based on the apparatus shown in fig. 8, the present embodiment proposes another file storage apparatus, as shown in fig. 9, the apparatus may be applied to a client device, and the target storage space may be a persistent storage space, and the apparatus may further include: a first obtaining unit 1000 and a first downloading unit 2000, wherein:
the first obtaining unit 1000 may be configured to obtain, before the target storage space of the target file to be stored is determined, a download address of the target file issued by a server device in communication connection with the client device;
the client device may include a mobile phone, a tablet computer, a desktop computer, and the like, and the specific device type of the client device is not limited in the present invention.
The persistent storage space is a data storage space of a disk, a U disk and the like which can persistently store files. It should be noted that, in the client device, as opposed to the target storage space in which the file can be persistently stored, the memory of the client device can only temporarily store the file, and when power is off or shutdown occurs, the file or data stored in the memory of the client device may be lost.
Specifically, the target storage space may be a certain data storage space in the client device.
The server device is a device capable of performing data transmission with the client device.
Specifically, the communication connection between the server device and the client device may be a bluetooth connection, a wireless network connection, a network cable connection, and the like, which is not limited in the present invention.
The target file may be a file obtained through network downloading.
The present invention does not limit the specific type of the download address of the target file.
It should be understood that the location of the download address of the target file may be the server device, the client device itself, or other devices, which is not limited in the present invention.
The first downloading unit 2000 may be configured to download the target file from the downloading address to the memory of the client device.
Specifically, after downloading the target file to the memory of the client device, the present invention may execute a scheme composed of the first determining unit 100, the second determining unit 200, the algorithm value determining unit 300, the file saving unit 400, and the file storing unit 410, so as to save the target file from the memory of the client device to the target storage space capable of persistently storing the file on the premise of avoiding the file content loss in the target storage space. Of course, if the target storage space stores a duplicate file having the same file name and file content as the target file, the present invention may not store the target file in the target storage space.
It should be further noted that, after the target file is stored in the target storage space from the memory of the client device, the target file in the memory of the client device may be deleted, and the memory of the client device may be released in time, so as to improve the processing efficiency of the client device.
When the file storage device provided by this embodiment is applied to the client device, the target file is downloaded from the download address of the target file to the memory of the client device in advance for temporary storage, so that the client device can obtain the target file in time, and the client device can have a faster operation speed when performing data processing on the target file in the memory subsequently.
Based on the apparatus shown in fig. 8, this embodiment proposes another file storage apparatus, as shown in fig. 10, the apparatus may be applied to a client device, and the target storage space may be a persistent storage space, and the apparatus may further include: the second obtaining unit 1100 is configured to obtain,
the second obtaining unit 1100 may be configured to obtain, before the target storage space of the target file to be stored is determined, a download address of the target file, a file name of the target file, and a file content algorithm value of the target file, where the download address is issued by a server device in communication connection with the client device;
when the download address, the file name and the file content algorithm value of the target file are issued, the issuing sequence of the download address, the file name and the file content algorithm value of the target file is not limited.
If the target file is not downloaded by the client device, that is, the file with the same file name and the same file content algorithm value as the target file exists in the target storage space, the target file does not need to be downloaded to the client device, so that resource consumption generated in the process of downloading the target file by the client device is reduced.
In this apparatus, the second determining unit 200 may specifically be configured to:
determining whether a duplicate file with the same file name as the target file exists in the target storage space according to the file name of the target file issued by the server device, and if so, executing the algorithm value judgment unit 300;
it should be further noted that, the present invention may compare the file name of the target file with the file names of the files in the target storage space before the client device downloads the target file, that is, according to the file name of the target file issued by the server device, and the client device does not need to execute the process of extracting the file name from the target file after downloading the target file, so that the client device may avoid resource consumption caused by extracting the file name from the target file, and reduce the computation amount of the client device.
In this apparatus, the algorithm value determining unit 300 may specifically be configured to:
judging whether the file content algorithm value of the duplicate name file is the same as the file content algorithm value of the target file issued by the server device, wherein the file content algorithm value is related to the file content of the file, and if so, executing the file storage unit 400; if not, executing the file storage unit 410;
it should be further noted that, the present invention may compare the file content algorithm value of the target file with the file content algorithm value of the duplicate name file in the client device before the client device downloads the target file, that is, according to the file content algorithm value of the target file issued by the server device, without the client device executing the calculation process of the file content algorithm value of the target file after downloading the target file, so that the client device may avoid resource consumption caused by calculating the file content algorithm value of the target file, and reduce the computation load of the client device.
In this apparatus, the file saving unit 400 may be specifically configured to:
downloading the target file from the download address of the target file and storing the target file in the target storage space to cover the rename file;
or discarding the download address of the target file to avoid downloading the target file from the download address of the target file, so that the rename file is continuously saved in the target storage space.
It should be noted that, if it is determined that the file with the same file name and file content algorithm value as the target file is stored in the target storage space before the client device downloads the target file, the target file may be directly downloaded to the target storage space of the client device to cover the renamed file according to the download address of the target file issued by the server device.
Of course, the present invention can also avoid downloading the target file to the client device by discarding the download address of the target file issued by the server device. At this time, the rename file with the same file name and file content as the target file can be continuously stored in the target storage space, so that the loss of the file content is avoided, and meanwhile, the resource consumption caused by downloading the target file by the client device can also be avoided.
Specifically, when the file storage unit 410 is operated, because the target file is not downloaded to the client device, the file name of the rename file can be modified, so that the file names of the target file and the rename file are different.
According to the file storage device provided by the embodiment, before the target file is downloaded by the client device, whether the file with the same file name and the same file content algorithm value as those of the target file is stored in the target storage space is determined, and whether the target file needs to be downloaded to the target storage space is further determined, so that the client device does not need to download the target file when the file with the same file name and the same file content algorithm value as those of the target file is stored in the target storage space, and resource consumption caused by downloading the target file by the client device is avoided.
Based on the apparatus shown in fig. 8, this embodiment proposes another file storage apparatus, as shown in fig. 11, the apparatus may be applied to a client device, and the target storage space may be a persistent storage space, and the apparatus may further include: a third obtaining unit 1200 and a second downloading unit 210.
The third obtaining unit 1200 may be configured to:
before the target storage space of the target file to be stored is determined, acquiring a download address of the target file and a file name of the target file, wherein the download address is issued by a server device in communication connection with the client device;
it should be noted that, in order to avoid resource consumption caused by the server device calculating the file content algorithm value and reduce the dependence of the client device on the server device, the present invention may only issue the download address of the target file and the file name of the target file from the server device to the client device before the client device downloads the target file, and the file content algorithm value of the target file may be obtained by the client device calculating the file content of the target file after downloading the target file.
In this apparatus, the second determining unit 200 may specifically be configured to:
determining whether a duplicate file with the same file name as the target file exists in the target storage space according to the file name of the target file issued by the server device, and if so, executing the algorithm value judgment unit 300;
the second downloading unit 210 may be configured to:
downloading the target file from the download address to a memory of the client device;
it should be noted that, no matter what the judgment result of the second determining unit 200 is, the second downloading unit 210 may be operated by the present invention.
It should be further noted that, the sequential execution order of the second determining unit 200 and the second downloading unit 210 is not limited in the present invention.
In this apparatus, the algorithm value determining unit 300 may specifically be configured to:
judging whether the file content algorithm value of the rename file is the same as the file content algorithm value of the target file in the memory, wherein the file content algorithm value is related to the file content of the file, and if so, executing the file saving unit 400; if not, executing the file storage unit 410;
specifically, the method and the device can calculate the file content algorithm value of the target file in the client device after the client device downloads the target file so as to compare the file content algorithm value of the target file with the file content algorithm value of the rename file.
It should be noted that, after the client device downloads the target file, the file content algorithm value of the target file is obtained by calculating the file content algorithm value of the target file in the client device, so that the server device is not needed to calculate the file content algorithm value, the resource consumption of the server device is reduced, and the dependence of the client device on the server device is reduced.
In this apparatus, the file saving unit 400 may be configured to:
storing the target file in the memory of the client device to the target storage space to cover the rename file;
or deleting the target file in the memory of the client device to avoid the target file from being stored in the target storage space, so that the duplicate name file is continuously stored in the target storage space.
When the file storage device provided by this embodiment is applied to the client device, the file content algorithm value of the target file is obtained by calculating the file content algorithm value of the target file in the client device, so that resource consumption of the server device can be reduced, and dependence of the client device on the server device can be reduced.
Based on the apparatus shown in fig. 9, the present embodiment proposes another file storage apparatus, as shown in fig. 12, the apparatus may further include: a fourth obtaining unit 500, a fifth obtaining unit 600, and a path saving unit 700, wherein:
the fourth obtaining unit 500 may be configured to obtain a file identifier of a target file issued by a server device in communication connection with the client device;
it should be noted that the client device may download the target file with the same file name through the server device for multiple times. Therefore, in order to accurately count the related information (such as the number of times of downloading a certain target file) of all target files downloaded by the client device through the server device and avoid uncertainty in the process of counting the duplicate name files, the method and the device can uniquely identify the target files.
The file identifier of the target file may be a unique identifier of the target file. The file identifier of the target file may be one or more of numbers, letters, punctuation marks and other characters, which is not limited in the present invention.
Specifically, the present invention may operate the fourth obtaining unit 500 after the first obtaining unit 1000, or may operate the fourth obtaining unit 500 before the first obtaining unit 1000. Of course, the present invention may also operate the first obtaining unit 1000 and the fourth obtaining unit 500 at the same time.
It should be noted that the file identifiers of the target files obtained from the server device each time in the present invention may be different, so as to accurately count all the target files downloaded by the client device through the server device. Even if the target files downloaded by the server device are the same, the file identifications of the target files obtained from the server device can be different.
The fifth obtaining unit 600 may be configured to obtain a file storage path of the target file stored in the target storage space in the client device;
it should be noted that, after the target file is stored in the target storage space, the file storage path of the target file stored in the target storage space in the client device may be obtained.
Optionally, if the file saving unit 400 is operated and the target file is saved in the target storage space, the fifth obtaining unit 600 may be operated after the file saving unit 400 is operated;
alternatively, if the file storage unit 410 is operated, the fifth obtaining unit 600 may be operated after the file storage unit 410.
The path saving unit 700 may be configured to correspondingly save the file identifier of the target file and the file storage path to a database of the client device.
Specifically, the present invention may establish a data table corresponding to the target storage space in a database of the client device, and after the target file is stored in the target storage space, correspondingly store the obtained file identifier of the target file and the file storage path of the target file in the data table corresponding to the target storage space.
Specifically, the file storage method and the device can correspondingly store the file identifications and the file storage paths of the plurality of target files stored in the target storage space in the same data table.
It is understood that the fourth obtaining unit 500, the fifth obtaining unit 600, and the path saving unit 700 may also be applied to the file storage apparatus shown in fig. 10 and 11.
According to the file storage device provided by the embodiment, the file identification of the target file and the corresponding file storage address are stored in the data table of the database, so that the target file required by the user can be quickly searched, the searching efficiency of the user for the required target file is improved, and the resource consumption of the client device during working is reduced.
Based on the apparatus shown in fig. 12, this embodiment proposes another file storage apparatus, and the path saving unit 700 may be specifically configured to:
and correspondingly storing the file identifier of the target file, the file storage path and the file name of the target file stored in the target storage space into a database of the client equipment.
It is understood that, in order to ensure the accuracy of the file name of the recorded target file, the file name of the target file recorded in the database according to the present invention should be the file name of the target file already stored in the target storage space.
It should be noted that, the file name of the target file stored in the target storage space is recorded in the data table of the database, so that when the new target file to be stored is compared with the file names of the files in the target storage space, the file name of each file stored in the target storage space can be directly extracted from the data table of the database, and the extraction of each file is not required, thereby reducing the resource consumption of the client device.
The file storage apparatus according to this embodiment may reduce resource consumption of the client device by recording the file name of the target file stored in the target storage space in the data table of the database.
Based on the apparatus shown in fig. 12, this embodiment proposes another file storage apparatus, where the path saving unit 700 may be specifically configured to:
correspondingly storing the file identification of the target file, the file storage path and the file content algorithm value of the target file into a database of the client device;
it should be noted that, the file content algorithm value of the target file is in the data table of the database, and when the new target file to be stored is compared with the file content algorithm value of each file in the target storage space, the file content algorithm value of each file stored in the target storage space can be directly extracted from the data table of the database, and the calculation of the file content algorithm value of each file is not required, so that the resource consumption of the client device can be reduced.
Optionally, in another file storage apparatus proposed in this embodiment, the path saving unit 700 may also be specifically configured to:
and correspondingly storing the file identifier of the target file, the file storage path, the file name of the target file stored in the target storage space and the file content algorithm value of the target file into a database of the client device.
It can be understood that, the file name of the target file stored in the target storage space and the file content algorithm value of the target file are both recorded in the data table of the database, so that when the new target file to be stored is compared with each file in the target storage space by the file name and the file content algorithm value, the file name and the file content algorithm value of each file stored in the target storage space can be directly extracted from the data table of the database, and the resource consumption of the client device is further reduced.
The file storage apparatus provided in this embodiment may reduce resource consumption of the client device by recording the file content algorithm value of the target file in the data table of the database.
It should also be noted that 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 the process, method, article, or apparatus that comprises the element.
The above are merely examples of the present application and are not intended to limit the present application. Various modifications and changes may occur to those skilled in the art. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present application should be included in the scope of the claims of the present application.

Claims (10)

1. A method of file storage, the method comprising:
determining a target storage space of a target file to be stored;
determining whether a duplicate name file with the same file name as the target file exists in the target storage space, if so, judging whether a file content algorithm value of the duplicate name file is the same as a file content algorithm value of the target file, wherein the file content algorithm value is related to the file content of the file;
if the duplicate name file is the same as the duplicate name file, saving the duplicate name file or the target file in the target storage space;
and if not, modifying the file name of the target file and/or the file name of the duplicate name file to enable the target file and the duplicate name file to have a difference, and storing the target file having the difference with the file name of the duplicate name file into the target storage space.
2. The method of claim 1, wherein the method is applied to a client device, wherein the target storage space is a persistent storage space, and wherein before the determining a target storage space for a target file to be stored, the method further comprises:
acquiring a download address of the target file issued by a server device in communication connection with the client device;
and downloading the target file from the download address to the memory of the client device.
3. The method of claim 1, wherein the method is applied to a client device, wherein the target storage space is a persistent storage space, and wherein before the determining a target storage space for a target file to be stored, the method further comprises:
acquiring a download address of the target file, a file name of the target file and a file content algorithm value of the target file issued by a server device in communication connection with the client device;
the determining whether a duplicate name file with the same file name as the target file exists in the target storage space includes: determining whether a duplicate name file with the same file name as the target file exists in the target storage space according to the file name of the target file issued by the server side equipment;
the judging whether the file content algorithm value of the rename file is the same as the file content algorithm value of the target file comprises the following steps:
judging whether the file content algorithm value of the duplicate name file is the same as the file content algorithm value of the target file issued by the server device;
the saving the rename file or the target file in the target storage space includes:
downloading the target file from the download address of the target file and storing the target file in the target storage space to cover the rename file;
or discarding the download address of the target file to avoid downloading the target file from the download address of the target file, so that the rename file is continuously saved in the target storage space.
4. The method of claim 1, wherein the method is applied to a client device, wherein the target storage space is a persistent storage space, and wherein before the determining a target storage space for a target file to be stored, the method further comprises:
acquiring a download address of the target file and a file name of the target file issued by a server device in communication connection with the client device;
the determining whether a duplicate name file with the same file name as the target file exists in the target storage space includes: determining whether a duplicate name file with the same file name as the target file exists in the target storage space according to the file name of the target file issued by the server side equipment;
the method further comprises the following steps: downloading the target file from the download address to a memory of the client device;
the judging whether the file content algorithm value of the rename file is the same as the file content algorithm value of the target file comprises the following steps:
judging whether the file content algorithm value of the duplicate name file is the same as the file content algorithm value of the target file in the memory;
the saving the rename file or the target file in the target storage space includes:
storing the target file in the memory of the client device to the target storage space to cover the rename file;
or deleting the target file in the memory of the client device to avoid the target file from being stored in the target storage space, so that the duplicate name file is continuously stored in the target storage space.
5. The method according to any one of claims 2 to 4, further comprising:
acquiring a file identifier of a target file issued by server equipment in communication connection with the client equipment;
obtaining a file storage path of the target file stored in the target storage space in the client device;
and correspondingly storing the file identification of the target file and the file storage path into a database of the client equipment.
6. The method of claim 5, wherein saving the file identifier of the target file and the file storage path association to a database of the client device comprises:
correspondingly storing the file identifier of the target file, the file storage path and the file name of the target file stored in the target storage space into a database of the client device;
or correspondingly storing the file identifier of the target file, the file storage path and the file content algorithm value of the target file into a database of the client device;
or correspondingly storing the file identifier of the target file, the file storage path, the file name of the target file stored in the target storage space and the file content algorithm value of the target file into a database of the client device.
7. A file storage apparatus, the apparatus comprising: the device comprises a first determining unit, a second determining unit, an algorithm value judging unit, a file saving unit and a file storing unit, wherein:
the first determining unit is used for determining a target storage space of a target file to be stored;
the second determining unit is used for determining whether a duplicate name file with the same file name as the target file exists in the target storage space, and if so, the algorithm value judging unit is executed;
the algorithm value judging unit is used for judging whether the file content algorithm value of the rename file is the same as the file content algorithm value of the target file, wherein the file content algorithm value is related to the file content of the file, and if the file content algorithm value is the same as the file content algorithm value of the rename file, the file saving unit is executed; if not, executing the file storage unit;
the file saving unit is used for saving the duplicate name file or the target file in the target storage space;
the file storage unit is used for modifying the file name of the target file and/or the file name of the duplicate name file so that the target file and the duplicate name file have difference, and storing the target file which has difference with the file name of the duplicate name file into the target storage space.
8. The apparatus of claim 7, wherein the apparatus is applied to a client device, and wherein the target storage space is a persistent storage space, the apparatus further comprising: a first obtaining unit and a first downloading unit, wherein:
the first obtaining unit is configured to obtain, before the target storage space of the target file to be stored is determined, a download address of the target file issued by a server device in communication connection with the client device;
the first downloading unit is configured to download the target file from the downloading address to the memory of the client device.
9. The apparatus of claim 7, wherein the apparatus is applied to a client device, and wherein the target storage space is a persistent storage space, the apparatus further comprising: a second obtaining unit for obtaining the second data,
the second obtaining unit is configured to obtain, before the target storage space of the target file to be stored is determined, a download address of the target file, a file name of the target file, and a file content algorithm value of the target file, where the download address of the target file is issued by a server device in communication connection with the client device;
the second determining unit is specifically configured to:
determining whether a duplicate file with the same file name as the target file exists in the target storage space according to the file name of the target file issued by the server device, and if so, executing the algorithm value judgment unit;
the algorithm value judging unit is specifically configured to:
judging whether the file content algorithm value of the duplicate name file is the same as the file content algorithm value of the target file issued by the server device, wherein the file content algorithm value is related to the file content of the file, and if so, executing the file storage unit; if not, executing the file storage unit;
the file saving unit is specifically configured to:
downloading the target file from the download address of the target file and storing the target file in the target storage space to cover the rename file;
or discarding the download address of the target file to avoid downloading the target file from the download address of the target file, so that the rename file is continuously saved in the target storage space.
10. The apparatus of claim 7, wherein the apparatus is applied to a client device, and wherein the target storage space is a persistent storage space, the apparatus further comprising: a third obtaining unit and a second downloading unit;
the third obtaining unit is configured to:
before the target storage space of the target file to be stored is determined, acquiring a download address of the target file and a file name of the target file, wherein the download address is issued by a server device in communication connection with the client device;
the second determining unit is specifically configured to:
determining whether a duplicate file with the same file name as the target file exists in the target storage space according to the file name of the target file issued by the server device, and if so, executing the algorithm value judgment unit;
the second downloading unit is configured to:
downloading the target file from the download address to a memory of the client device;
the algorithm value judging unit is specifically configured to:
judging whether the file content algorithm value of the rename file is the same as the file content algorithm value of the target file in the memory, wherein the file content algorithm value is related to the file content of the file, and if so, executing the file storage unit; if not, executing the file storage unit;
the file saving unit is used for:
storing the target file in the memory of the client device to the target storage space to cover the rename file;
or deleting the target file in the memory of the client device to avoid the target file from being stored in the target storage space, so that the duplicate name file is continuously stored in the target storage space.
CN202010633970.0A 2020-07-02 2020-07-02 File storage method and device Pending CN111782594A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202010633970.0A CN111782594A (en) 2020-07-02 2020-07-02 File storage method and device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202010633970.0A CN111782594A (en) 2020-07-02 2020-07-02 File storage method and device

Publications (1)

Publication Number Publication Date
CN111782594A true CN111782594A (en) 2020-10-16

Family

ID=72759367

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202010633970.0A Pending CN111782594A (en) 2020-07-02 2020-07-02 File storage method and device

Country Status (1)

Country Link
CN (1) CN111782594A (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114546280A (en) * 2022-02-25 2022-05-27 创新奇智(重庆)科技有限公司 File storage method and device, electronic equipment and computer readable storage medium

Citations (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN104247376A (en) * 2013-04-02 2014-12-24 华为技术有限公司 File uploading method in cloud storage, client, application server, and cloud storage system
CN106412033A (en) * 2016-09-14 2017-02-15 广东欧珀移动通信有限公司 Data migration method and terminal
CN106649721A (en) * 2016-12-22 2017-05-10 创新科存储技术有限公司 Method and device for duplication removal of file
CN106844431A (en) * 2016-12-12 2017-06-13 北京猎豹移动科技有限公司 File memory method, device and its electronic equipment
CN110516477A (en) * 2019-07-29 2019-11-29 浪潮电子信息产业股份有限公司 Document handling method and device
CN110928497A (en) * 2019-11-15 2020-03-27 浪潮电子信息产业股份有限公司 Metadata processing method, device and equipment and readable storage medium
CN111198848A (en) * 2020-01-03 2020-05-26 南京领行科技股份有限公司 Distributed file access method, system, server and storage medium

Patent Citations (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN104247376A (en) * 2013-04-02 2014-12-24 华为技术有限公司 File uploading method in cloud storage, client, application server, and cloud storage system
CN106412033A (en) * 2016-09-14 2017-02-15 广东欧珀移动通信有限公司 Data migration method and terminal
CN106844431A (en) * 2016-12-12 2017-06-13 北京猎豹移动科技有限公司 File memory method, device and its electronic equipment
CN106649721A (en) * 2016-12-22 2017-05-10 创新科存储技术有限公司 Method and device for duplication removal of file
CN110516477A (en) * 2019-07-29 2019-11-29 浪潮电子信息产业股份有限公司 Document handling method and device
CN110928497A (en) * 2019-11-15 2020-03-27 浪潮电子信息产业股份有限公司 Metadata processing method, device and equipment and readable storage medium
CN111198848A (en) * 2020-01-03 2020-05-26 南京领行科技股份有限公司 Distributed file access method, system, server and storage medium

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114546280A (en) * 2022-02-25 2022-05-27 创新奇智(重庆)科技有限公司 File storage method and device, electronic equipment and computer readable storage medium

Similar Documents

Publication Publication Date Title
JP6629697B2 (en) Method and apparatus for extracting a virtual machine image file
US9251160B1 (en) Data transfer between dissimilar deduplication systems
US11210269B2 (en) System and method for deduplicating container image storage data
CN107911461B (en) Object processing method in cloud storage system, storage server and cloud storage system
CN106708825B (en) A kind of data file processing method and system
CN109033360B (en) Data query method, device, server and storage medium
WO2010064116A1 (en) Method, apparatus and computer program product for sub-file level synchronization
CN109271391A (en) Date storage method, server, storage medium and device
CN111198856B (en) File management method, device, computer equipment and storage medium
CN110347651A (en) Method of data synchronization, device, equipment and storage medium based on cloud storage
CN108762979B (en) Terminal information backup method and backup device based on matching tree
US20140012809A1 (en) Method for Implementing Electronic Bookmarks and Device Thereof
CN110297781B (en) Method for recovering deleted data in APFS (advanced File System) based on copy-on-write
CN115576600A (en) Code change-based difference processing method and device, terminal and storage medium
CN111782594A (en) File storage method and device
CN109408471B (en) Compressed packet decompression method and device based on matching tree and storage medium
CN100357943C (en) A method for inspecting garbage files in cluster file system
CN107844483B (en) File management method and device
JP2010277517A (en) File management server, file management system, file management program and file management method
US7778660B2 (en) Mobile communications terminal, information transmitting system and information receiving method
CN102932513B (en) A kind of business card maintaining method, device and equipment
CN109325057B (en) Middleware management method, device, computer equipment and storage medium
CN108228226B (en) Hard link differential method and device and corresponding terminal
EP2164005B1 (en) Content addressable storage systems and methods employing searchable blocks
CN111221788A (en) Data transmission method and system

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination