WO2014206346A1 - Method and device for synchronizing terminal and server - Google Patents

Method and device for synchronizing terminal and server Download PDF

Info

Publication number
WO2014206346A1
WO2014206346A1 PCT/CN2014/080993 CN2014080993W WO2014206346A1 WO 2014206346 A1 WO2014206346 A1 WO 2014206346A1 CN 2014080993 W CN2014080993 W CN 2014080993W WO 2014206346 A1 WO2014206346 A1 WO 2014206346A1
Authority
WO
WIPO (PCT)
Prior art keywords
file
directory
metadata
identifier
terminal
Prior art date
Application number
PCT/CN2014/080993
Other languages
French (fr)
Chinese (zh)
Inventor
陈跃泉
Original Assignee
华为技术有限公司
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 华为技术有限公司 filed Critical 华为技术有限公司
Publication of WO2014206346A1 publication Critical patent/WO2014206346A1/en

Links

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/01Protocols
    • H04L67/10Protocols in which an application is distributed across nodes in the network
    • H04L67/1095Replication or mirroring of data, e.g. scheduling or transport for data synchronisation between network nodes
    • 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/17Details of further file system functions
    • G06F16/178Techniques for file synchronisation in file systems
    • 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/18File system types
    • G06F16/182Distributed file systems
    • G06F16/1824Distributed file systems implemented using Network-attached Storage [NAS] architecture
    • G06F16/183Provision of network file services by network file servers, e.g. by using NFS, CIFS

Definitions

  • the invention relates to a method and a device for synchronizing a terminal with a server.
  • the application for the application of the method and device for synchronizing the terminal and the server is disclosed in the application No. 201310270933. Priority is hereby incorporated by reference in its entirety.
  • the present invention relates to the field of communications technologies, and in particular, to a method and apparatus for synchronizing a terminal with a server. Background technique
  • the cloud supports mobile phones, personal computers (PCs), web pages, and other clients to synchronize with the files in the cloud in real time, ensuring that the user's local data and the cloud data are consistent without user intervention, so that the user can Whenever and wherever you are, you are guaranteed to get the latest data and give the user a good experience.
  • PCs personal computers
  • web pages web pages
  • other clients to synchronize with the files in the cloud in real time, ensuring that the user's local data and the cloud data are consistent without user intervention, so that the user can Whenever and wherever you are, you are guaranteed to get the latest data and give the user a good experience.
  • Full-scale synchronization means that when the cloud is updated, the client needs to obtain the full amount of data from the server to the local client, and then compare the local client data with the data obtained from the cloud, obtain the inconsistent data, and finally synchronize the inconsistent data. Among them, obtaining full data from the cloud requires a large amount of user traffic.
  • Incremental synchronization means that when there is an update in the cloud, the client and the cloud only synchronize the updated data without obtaining all the data. Therefore, the user's traffic can be greatly reduced.
  • the embodiment of the invention provides a method and a device for synchronizing a terminal with a server to solve the problem of waste of traffic and link failure when the client and the cloud synchronize the mobile operation.
  • a terminal synchronizes with a server, including:
  • the server receives a request to move the file from the first directory to the second directory, the request carrying the identifier of the file and the identifier of the second directory;
  • the server searches for metadata of the file according to the identifier of the file, and changes a parent directory identifier of the file to an identifier of the second directory in the metadata of the file, and creates the file in the first directory.
  • Proxy metadata of the file the proxy metadata is used to indicate that the file has been moved to a second directory;
  • the server sends the proxy metadata of the file to the terminal to perform synchronization between the server and the terminal through the file local to the terminal.
  • the proxy metadata includes an identifier of the file, an identifier of the second directory, and a mobile label indicating that the file has moved;
  • the method further includes:
  • the method further includes: The metadata of the piece is sent to the terminal;
  • the terminal updates the first directory in the terminal according to the proxy metadata of the file, and updates the second directory in the terminal according to the metadata of the file.
  • the metadata of the file includes an identifier of the file and an identifier of the second directory;
  • Updating the second directory in the terminal according to the metadata of the file specifically includes: the terminal locally searching for metadata of the file according to the identifier of the file in the metadata of the file;
  • the proxy metadata includes an identifier of the file, an identifier of the second directory, and is used to indicate that the file has occurred Moving move marker
  • the first directory specific item in the terminal according to the proxy metadata of the file includes:
  • the file is set to be hidden in the metadata of the found file
  • the file is not processed.
  • the terminal locally searches for the element of the file according to the identifier of the file in the metadata of the file.
  • the method further includes: determining a state of the file, and if the file is in a hidden state, changing the file to a display state in metadata of the file.
  • proxy metadata for indicating that the file has been removed from the second directory under the second directory, the proxy metadata is deleted.
  • a method for synchronizing a terminal with a server includes:
  • the terminal Receiving proxy metadata of the file from the server, the proxy metadata is used to indicate that the file has been moved to a second directory;
  • the terminal searches the metadata of the file locally in the terminal according to the proxy metadata, and completes synchronization with the server by using the metadata of the file found locally.
  • the proxy metadata includes an identifier of the file, an identifier of the second directory, and a mobile tag indicating that the file has moved;
  • the terminal searches the metadata of the file locally in the terminal according to the proxy metadata, and completes synchronization with the server by using the metadata of the file found locally:
  • the performing the synchronization with the server by using the metadata of the file that is locally found specifically includes:: metadata of the file that is found locally Completing the first directory in the terminal and the first in the server Synchronization of a directory;
  • the method further includes:
  • the terminal completes synchronization of the second directory in the terminal with the second directory in the server according to the received metadata of the file.
  • the metadata of the file received from the server includes an identifier of the file and a second directory Identification
  • the synchronizing the second directory in the terminal with the second directory in the server according to the metadata of the file includes:
  • the terminal locally searches for metadata of the file according to the identifier of the file in the received metadata of the file;
  • the proxy metadata includes an identifier of the file, an identifier of the second directory, and is used to indicate that the file has occurred Moving move marker
  • the terminal searches the metadata of the file locally in the terminal according to the proxy metadata, and completes the first directory in the terminal and the first in the server by using the metadata of the file found locally.
  • the synchronization of the directory specifically includes:
  • the file is set to be hidden in the metadata of the found file
  • the file is not deal with.
  • the terminal finds the element of the file locally according to the identifier of the file in the metadata of the file. After the data, the method further includes: determining a state of the file, and if the file is in a hidden state, changing the file to a display state in metadata of the file.
  • a server that synchronizes with a terminal, the server includes: a receiving unit, configured to receive a request for moving a file from a first directory to a second directory, where the request carries an identifier and a location of the file The identifier of the second directory;
  • a processing unit configured to search for metadata of the file according to the identifier of the file, change a parent directory identifier of the file to an identifier of the second directory in the metadata of the file, and in the Creating a proxy metadata of the file in a directory, the proxy metadata is used to indicate that the file has been moved to the second directory;
  • a synchronization unit configured to send proxy metadata of the file to the terminal, to perform synchronization between the server and the terminal by using the file local to the terminal.
  • the synchronization unit is further configured to send metadata of the file to the terminal, and proxy metadata of the file is used to synchronize the first directory, where The metadata of the file is used to synchronize the second directory.
  • the processing unit when changing a parent directory identifier of the file to an identifier of the second directory And further determining whether there is proxy metadata for indicating that the file has been removed from the second directory under the second directory; if the second directory exists to indicate that the file has been The proxy metadata removed by the second directory deletes the proxy metadata under the second directory.
  • a terminal for synchronizing with a server comprising: a synchronization unit, configured to move the file from a first directory to a first manner by changing a parent directory identifier of the file in metadata of a file After the second directory, and the proxy metadata of the file is created in the first directory, the proxy metadata of the file is received from the server and provided to the processing unit, where the proxy metadata is used to indicate that the file has been Move to the second directory;
  • the processing unit is configured to search for metadata of the file locally in the terminal according to the proxy metadata, and complete synchronization with the server by using metadata of the file found locally.
  • the proxy metadata includes an identifier of the first file, an identifier of the second directory, and a mobile tag used to indicate that the file has moved; The movement has occurred; the metadata of the file is locally searched according to the identifier of the file; the parent directory identifier of the file is changed to the identifier of the second directory in the found metadata of the file.
  • the synchronization unit is further configured to receive metadata of the file from the server;
  • the processing unit specifically includes:
  • a first operation module configured to search for metadata of the file locally in the terminal according to the proxy metadata, and complete the local first directory and the first in the server by using the metadata of the file locally found Synchronization of a directory;
  • a second operation module configured to complete synchronization of the local second directory with the second directory in the server according to the received metadata of the file.
  • the metadata of the file received from the server includes an identifier of the file and a second directory Identification
  • the second operation module is specifically configured to locally search for metadata of the file according to the identifier of the file in the metadata of the received file, where the metadata of the file is found The parent directory ID of the file is changed to the identity of the second directory.
  • the proxy metadata includes an identifier of the file, an identifier of the second directory, and is used to indicate that the file has occurred Moving move marker
  • the first operation module is specifically configured to determine, according to the mobile tag in the proxy metadata The file has been moved; the metadata of the file is locally searched according to the identifier of the file in the proxy metadata; determining whether the parent directory identifier of the file in the metadata of the found file is the An identifier of the second directory; if the parent directory identifier of the file is not the identifier of the second directory, the file is set to be hidden in the metadata of the found file; if the parent directory of the file The identifier is an identifier of the second directory, and the file is not processed.
  • the second operating module is further configured to determine a state of the file after the metadata of the file is found, If the file is in a hidden state, the file is changed to a display state in the metadata of the file.
  • the server moves the file from the source directory to the destination directory by changing the parent directory of the file, and creates proxy metadata for the file that has been moved to the target directory in the source directory, so that the terminal is in the synchronization source directory and
  • the target directory it can be recognized that the mobile side operates on the server side, so that the local file is used to synchronize with the server without re-downloading the file from the server side, thereby saving network resources.
  • the present invention moves the file from the source directory to the destination directory by changing the parent directory of the file, so that the logical number of the file remains unchanged, so that the shared, public, and external links of the original associated file f can remain valid.
  • FIG. 2 is a flowchart of a method for synchronizing a terminal and a server according to an embodiment of the present invention
  • FIG. 3 is a flowchart of a method for synchronizing a terminal and a server according to another embodiment of the present invention
  • FIG. a schematic diagram of the movement of f
  • FIG. 6 is a schematic diagram of a network architecture according to an embodiment of the present invention
  • FIG. 7 is a schematic structural diagram of a server that synchronizes with a terminal according to an embodiment of the present invention
  • FIG. 8 is a schematic structural diagram of a server that synchronizes with a terminal according to another embodiment of the present invention
  • FIG. 9 is a schematic structural diagram of a terminal synchronized with a server according to another embodiment of the present invention.
  • FIG. 10 is a schematic structural diagram of a terminal synchronized with a server according to another embodiment of the present invention.
  • FIG. 11 is a schematic diagram showing the hardware structure of a server synchronized with a terminal according to an embodiment of the present invention.
  • FIG. 12 is a schematic diagram showing the hardware structure of a terminal synchronized with a server according to another embodiment of the present invention. detailed description
  • FIG. 2 is a flowchart of a method for synchronizing a terminal and a server according to an embodiment of the present invention, where the method includes:
  • the server receives a request for moving a file from a first directory to a second directory, where the request carries an identifier of the file and an identifier of the second directory.
  • the server may be a cloud synchronization server, configured to provide a cloud synchronization service, and synchronize files on multiple terminals of the user.
  • the terminal initiates a request to move the file from the first directory to the second directory to the server, to Causes the server to perform a move operation based on the request and synchronize the user's other terminals through the server.
  • the request in step S200 may also be sent by the user to the server through the web client, so that the server performs the mobile operation according to the request, and then synchronizes from the server to all or part of the user's terminal.
  • the request received by the server carries the identifier of the file to be moved and the identifier of the target directory of the file.
  • the source directory of the file to be moved is the first directory
  • the target directory is the second directory, so the request received by the server needs to carry the identifier of the second directory.
  • the identifier of the source directory of the file may or may not be carried.
  • the server searches for metadata of the file according to the identifier of the file carried in the request, changes the parent directory identifier of the file to the identifier of the second directory in the metadata of the file, and creates the file in the first directory.
  • the proxy metadata where the proxy metadata is used to indicate that the file has been moved to the second directory.
  • the server After the server recognizes that the received request is a request to perform a move operation, the server performs the operation of step S202.
  • the server may determine the received request as a request to perform a move operation according to the name of the request or the type of operation specified in the request.
  • the request can use the mobile operation request in the prior art, and will not be described here.
  • attributes of a file are usually defined by the metadata of the file.
  • ownership of files and directories can be defined by the parent directory entry in the metadata of the file.
  • the server may The metadata of the file corresponding to the file identifier is searched according to the file identifier carried in the request, and the parent directory identifier of the file is changed to the identifier of the second directory in the metadata of the file.
  • the server also needs to create proxy metadata for the file in the source directory of the file (ie, under the first directory) to indicate that the file has been moved to the second directory by the proxy metadata when the first directory is synchronized with the terminal.
  • the proxy metadata of the file may be composed of the metadata of the file plus the mobile tag, or the partial data in the metadata of the file plus the mobile tag. Wherein, the move marker is used to indicate that the file has moved.
  • the metadata of a file can include attributes such as the identifier of the file, the parent directory identifier of the file, and so on.
  • the proxy metadata of the file since the file has been moved to the target directory (ie, the second directory), the proxy metadata of the file may include the identifier of the file, the identifier of the second directory, and the mobile tag.
  • the server sends the proxy metadata of the file to the terminal, so as to synchronize between the server and the terminal through the file local to the terminal.
  • the synchronization in the embodiment of the present invention may be full synchronization or partial synchronization, and the terminal and the server may synchronize the first directory and the second directory respectively.
  • the server After determining the directory to be synchronized, the server detects the update data from the last synchronization in the directory to be synchronized, and transmits the detected update data to the terminal. For example, in this embodiment, when the server and the terminal synchronize the first directory, the server detects the update data of the first directory during the current synchronization and the last synchronization, and when determining that the update data includes the proxy metadata of the file, the first The proxy metadata of the file under the directory is sent to the terminal.
  • the terminal may learn the received metadata as the proxy metadata of the file according to the mobile tag in the proxy metadata, and then update the local file according to the proxy metadata to complete the server. Synchronization between. It should be noted that the synchronization between the server and the terminal can be initiated by the terminal. The server can determine the directory to be synchronized according to the synchronization request sent by the terminal.
  • the embodiment of the present invention moves the file from the first directory to the second directory by changing the parent directory of the file, and creates proxy metadata for the file that has been moved to the second directory in the first directory, so that the terminal is synchronized first.
  • the agent metadata indicating that the file is moved may be sent to the terminal, and the terminal may identify, by the agent metadata, that a mobile operation occurs on the server side, thereby completing synchronization with the server through the file local to the terminal, without The server side re-downloads files, saving network resources.
  • the present invention moves the file from the source directory to the destination directory by changing the parent directory of the file, so that the logical number of the file remains unchanged, so that the shared, public, and external links of the original associated file f remain valid.
  • the terminal may perform the following processing: the terminal determines, according to the mobile tag in the proxy metadata, that the file has moved; according to the file identifier carried in the proxy metadata. Find the metadata of the file locally; change the parent directory identifier of the file to the identifier of the second directory in the metadata of the file found.
  • the terminal directly changes the parent directory of the file to the second directory by locally finding the file corresponding to the proxy metadata, so that the file is locally moved between the directories without downloading from the server. Files, but still synchronized with the server.
  • the above embodiment describes the synchronization process of completing the file moving operation in the process of the terminal synchronizing the first directory with the server after the server moves the file from the first directory to the second directory.
  • the terminal may update the first directory in the terminal according to the proxy metadata of the file, or update the second directory during the synchronization process on the second directory.
  • the embodiment may further include: the server transmitting the metadata of the file to the terminal; the terminal updating the first directory in the terminal according to the proxy metadata of the file, and according to the The metadata of the file updates the second directory in the terminal.
  • the server detects the update data of the second directory during the current synchronization and the last synchronization, and when determining that the update data includes the metadata of the file moved to the second directory, The metadata of the file is sent to the terminal.
  • the metadata of the file may include an identification of the file and an identification of the second directory.
  • the updating, by the terminal, the second directory in the terminal according to the metadata of the file may include: the terminal locally searching for metadata of the file according to the identifier of the file carried in the metadata of the file sent by the server; and finding the metadata of the file in the file. Change the parent directory ID of the file to the ID of the second directory carried in the metadata of the received file.
  • the updating, by the terminal, the first directory in the terminal according to the proxy metadata of the file may include: the terminal locally searching for metadata of the file according to the file identifier carried in the proxy metadata; determining the parent of the file in the metadata of the found file. Whether the directory identifier is the identifier of the second directory carried in the proxy metadata; if the parent directory identifier of the file is not the identifier of the second directory, the file is set to be hidden in the metadata of the found file; if the file The parent directory identifier is the identifier of the second directory, and the file is not processed.
  • the terminal may first initiate synchronization of the first directory, and may also initiate synchronization of the second directory.
  • the terminal may directly change the parent directory in the metadata of the file.
  • the file is moved to the second directory, and the file in the first directory can also be set to be hidden without deleting the file. Among them, the file Set to hidden, in order to improve the user experience, so as not to change the second directory in the terminal when the terminal has not synchronized the second directory.
  • setting the file to be hidden can not only enable the terminal to find the file when synchronizing the second directory, but also without re-downloading the file from the server.
  • the first directory of the terminal and the file in the first directory of the server can also be consistent.
  • the terminal uses the method of changing the parent directory of the file when synchronizing the first directory, the operation does not conflict with the operation when the second directory is synchronized, but is executed twice in the metadata of the file. The same operation.
  • the operation when synchronizing the first directory or the second directory, it is possible to first determine whether the parent directory of the file has been changed to the second directory, and if it has been changed, there is no need to perform the changed operation.
  • the terminal may further include the following steps when synchronizing the second directory: after the terminal searches for metadata of the file to be synchronized, the terminal determines the status of the file. If the file is hidden, the file is further changed to the display state in the metadata of the file.
  • the file is moved from the source directory to the destination directory by changing the parent directory of the file, and the proxy metadata is created in the source directory for the file that has been moved to the target directory, so that the terminal is in the synchronization source directory and
  • the target directory it can be recognized that the mobile operation occurs on the server side, so that the mobile terminal performs the local operation according to the mobile operation without saving the file from the server side, thereby saving network resources.
  • the present invention moves the file from the source directory to the destination directory by changing the parent directory of the file, so that the logical number of the file remains unchanged, so that the shared, public, and external links of the original associated file f can remain valid.
  • the solution provided by the embodiment of the present invention When the solution provided by the embodiment of the present invention is specifically implemented, the following may exist: The user first moves the file f from the S directory to the D directory, and then moves the file f from the D directory back to the S directory.
  • the proxy metadata of the file f already exists under the S directory, in which case the proxy element Data is no longer necessary.
  • the server in step S102 when the server in step S102 changes the parent directory identifier of the file to the identifier of the second directory, the server may further include the following processing: determining whether the second directory exists for The proxy metadata indicating that the file has been removed from the second directory; if there is proxy metadata indicating that the file has been removed from the second directory under the second directory, the proxy metadata is deleted.
  • the server may also periodically clear the proxy metadata. Specifically, the server may set a time limit for the proxy metadata, and the server deletes the expired proxy metadata in the server according to the preset time limit.
  • the server may further send an update notification to the terminal that is synchronized with the server, that is, after step S202, the method may further include: sending the first directory and the terminal synchronized with the server. An update notification of the second directory, so that the terminal initiates a request to synchronize the first directory or the second directory according to the update notification.
  • the terminal synchronized with the server refers to the terminal that the user has registered with the server and established a connection with the server.
  • the user here refers to the user to which the updated file belongs. It should be noted that if the server initiates a request to move the file from the first directory to the second directory by one of the user's terminals in step S200, the server may not initiate the request when sending the update notification.
  • the terminal sends an update notification.
  • FIG. 3 is a flowchart of a method for synchronizing according to another embodiment of the present invention, where the method includes: S300, moving the file from the first directory to the second directory by changing a parent directory identifier of the file in metadata of the file, and creating proxy metadata of the file in the first directory
  • the terminal receives the proxy metadata of the file created by the server in the first directory from the server, and the proxy metadata is used to indicate that the file has been moved to the second directory.
  • the server After the server moves the file from the first directory to the second directory, the server creates the proxy metadata for the file in the first directory.
  • the server synchronizes with the terminal for the first directory, the update data of the first directory since the last synchronization is detected. Because the proxy metadata for the file is added to the first directory between this synchronization and the last synchronization.
  • the server detects the update data, it detects the proxy metadata of the file and sends the proxy metadata of the file as update data to the terminal.
  • the terminal searches for metadata of the file locally in the terminal according to the proxy metadata, and completes synchronization with the server by using metadata of the file found locally.
  • the proxy metadata may include an identifier of the file, an identifier of the second directory, and a mobile tag.
  • the mobile tag is used to indicate that the file has moved, and the target directory after the terminal receives the update data, that is, the current parent directory of the file.
  • the terminal searches the metadata of the file locally in the terminal according to the proxy metadata, and completes synchronization with the server by using the metadata of the file found locally.
  • the method may include: determining, by the terminal, the file according to the mobile tag in the proxy metadata. The movement has occurred; the metadata of the file is found locally according to the identifier of the file, and the parent directory identifier of the file is changed to the identifier of the second directory in the metadata of the file found.
  • the above embodiment describes that after the server moves the file from the first directory to the second directory, In the process of synchronizing the first directory with the server, the synchronization process of the file moving operation is completed.
  • the terminal may update the first directory in the terminal only according to the proxy metadata, and update the second directory during the synchronization process of the second directory.
  • the step of completing the synchronization with the server by using the metadata of the file that is locally found in step 302 may include: completing the metadata in the terminal by using the metadata of the file that is locally found.
  • the first directory is synchronized with the first directory in the server.
  • the embodiment may further include: the terminal receiving metadata of the file from the server, and the terminal completing the second directory in the terminal and the second in the server according to the received metadata of the file. Synchronization of the directory.
  • the server detects the update data of the second directory during the current synchronization and the last synchronization, and when determining that the update data includes the metadata of the file moved to the second directory, The metadata of the file is sent to the terminal.
  • the metadata of the file may include an identification of the file and an identification of the second directory.
  • the terminal may complete the synchronization of the second directory in the terminal with the second directory in the server according to the received metadata of the file.
  • the terminal may include: searching, by the terminal, the file according to the identifier of the file carried in the metadata of the received file. Metadata; in the metadata of the file found, the parent directory identifier of the file is changed to the identifier of the second directory carried in the metadata of the received file.
  • the agent metadata of the file may include an identification of the file, an identification of the second directory, and a mobile tag indicating that the file has moved.
  • the terminal searches for the metadata of the file in the terminal according to the proxy metadata of the file, and completes the synchronization between the first directory in the terminal and the first directory in the server by using the metadata of the file found locally.
  • the terminal may specifically include: Finding the metadata of the file locally according to the file identifier carried in the proxy metadata; determining the found In the metadata of the file, the parent directory identifier of the file is the identifier of the second directory carried in the proxy metadata; if the parent directory identifier of the file is not the identifier of the second directory, the metadata of the found file will be The file is set to be hidden; if the parent directory identifier of the file is the identifier of the second directory, the file is not processed.
  • the terminal may initiate synchronization of the first directory first, and may also initiate synchronization of the second directory.
  • the terminal may directly change the parent directory in the metadata of the file.
  • the file is moved to the second directory, and the file in the first directory can also be set to be hidden without deleting the file.
  • the file is set to be hidden to improve the user experience, so that the second directory in the terminal is changed when the terminal has not synchronized the second directory.
  • setting the file to be hidden can not only enable the terminal to find the file when it synchronizes the second directory, but does not have to re-download the file from the server.
  • the first directory of the terminal and the file in the first directory of the server are also consistent.
  • the terminal synchronizes the second directory first
  • the terminal synchronizes the first directory
  • the case where the parent directory identifier of the file has been changed to the identifier of the second directory occurs. Therefore, when the terminal determines that the parent directory identifier of the first file is the identifier of the second directory, the file is not processed.
  • the terminal may further determine whether the file is set to be hidden. If it is set to hide the state, the file is changed to the display state. If it is not set to the hidden state, no change is needed. The status of the file.
  • the server changes the file from the first directory by changing the parent directory of the file.
  • the directory is moved to the second directory, and the proxy metadata is created in the first directory for the file that has been moved to the second directory, so that when the terminal synchronizes the first directory with the server, the server can send the proxy metadata indicating that the file is moved.
  • the terminal can identify, by the proxy metadata, that a mobile operation occurs on the server side, thereby completing synchronization with the server through the local file of the terminal, without re-downloading the file from the server side, thereby saving network resources.
  • FIG. 4 is a flowchart of a synchronization method according to the embodiment, where the method specifically includes:
  • terminal A moves the file f in the local source directory S to the target directory D.
  • a file shift occurs in one of a plurality of terminals synchronized by the user and the server as an example. If the user uses the web client to operate the cloud server for file movement, step S400 may be omitted.
  • the attribution relationship between the file f and the directory can be described by the metadata of the file f.
  • the data structure of the metadata of the file f is as shown in Table 1:
  • the file identifier can be represented by the logical number of the file generated by the system.
  • the data structure of the metadata shown in Table 1 is only an example, and may include other attributes or only tables in specific applications.
  • Terminal A sends a request to move the file f from the directory S to the directory D to the cloud server.
  • the request may include an account of the user, an identifier of the file f, an identifier of the target directory D, and an operation type.
  • the operation type is a mobile operation.
  • the server creates the proxy metadata f, in the source directory S, and modifies the parent directory of the file f to the target directory D in the metadata of the file f.
  • the server obtains the data stored by the user in the cloud according to the account of the user carried in the received request. Find the metadata of file f in the user's data, and modify the parent directory of file f to the target directory D in the metadata of file f.
  • Fig. 5 is a schematic diagram of the movement of the file f. Before moving the directory A below the active directory S and the target directory D, the source directory S has a file f below. After the move, the source directory of the file f is stored under the source directory S, and the file f is located under the directory D.
  • the data structure of the proxy metadata ⁇ of file f is shown in Table 3: table 3
  • the server may also first check whether there is proxy metadata of the file f under the target directory D; if not, directly execute step S404; if there is proxy metadata of the file f under the target directory D, the server further deletes the target.
  • the proxy metadata of the file f under the directory D, and step S404 is performed.
  • the server pushes an update notification to the terminal B that the user synchronizes with the server.
  • the terminal may initiate a request to synchronize the first directory to the server, or may initiate a synchronization request according to an update notification sent by the server about the first directory. This embodiment is described by taking an example in which the server sends an update notification to the terminal.
  • the server can maintain the connection of the user's various online terminals. After the server detects that the user's data has been updated, it can send an update notification to each synchronization terminal that the user has connected to the server. When the update notification is initiated, it may no longer be sent to the terminal A initiating the mobile request.
  • the server may separately send an update notification of the source directory S and the target directory D, or may notify the update of the source directory S and the target directory D with an update notification.
  • the terminal B initiates a synchronization request for synchronizing the directory S to the server.
  • the synchronization request carries the identifier of the directory S and the synchronization token ring syncToken, and the synchronization token ring syncToken is used to indicate the serial number of each synchronization.
  • the server detects the update data in the directory S, and detects the update data as the file f.
  • the proxy metadata is returned to the terminal.
  • the server After receiving the request of the synchronization directory S initiated by the terminal B, the server returns the metadata of the newly added or modified file in the directory S. Specifically, the server detects all the update data from the source directory S since the last syncToken according to the syncToken requested by the terminal B, and simultaneously generates a new syncToken to perform the synchronizationTo the next time the terminal synchronizes, and finally the server returns the update data. And the new s yncToken.
  • the server detects the update data of the source directory S since 20121128000000 as the proxy metadata of the file ⁇ , returns the update data under the source directory S, and sets the new syncToken to 20121128120000.
  • terminal B sets the local file f to be hidden according to the proxy metadata returned by the server.
  • terminal B After receiving the update data returned by the server, terminal B determines that the file f has been removed from the directory S based on the movement flag in the data. Terminal B finds the metadata of file f locally, and sets file f to be hidden in the metadata of file f. Specifically, the data structure of the metadata of the file f set to be hidden is as shown in Table 4:
  • the file f After the file f is set to be hidden, the file f will not appear under the directory S, so that the directory S remains synchronized with the cloud. At the same time, it avoids deleting the file f, so that the subsequent directory is synchronized.
  • the file f can be directly moved to the directory D.
  • the terminal B can also change the parent directory of the file f to the directory D without setting the file f to be hidden, so that the file f can also be removed from the directory S.
  • this method causes the directory D to also change, affecting the user experience.
  • This embodiment is described by taking the file f as hidden as an example.
  • the terminal B initiates a synchronization request for synchronizing the directory D to the server.
  • the synchronization request carries the identifier of the directory D and the synchronization token ring syncToken.
  • the server detects the update data in the directory D, and when detecting the update data as the metadata of the file f, returns the metadata of the file f to the terminal.
  • step S41 For the process of detecting the update data by the server, refer to the description in step S41 0, which is not described here.
  • terminal B changes the parent directory of the local file f to the directory D according to the metadata of the server returning the file f.
  • the terminal B After receiving the metadata of the file f, the terminal B finds that the parent directory of the file f is changed to the directory D, and then searches for the metadata of the local file f, and changes the parent directory of f to the directory D in the found metadata. In addition, the terminal B further judges the state of the file f. If the file f has been set to the hidden state, the terminal B further changes the state of the file f to the display state.
  • terminal B may synchronize the directory S first, or may synchronize the directory D first.
  • the foregoing method embodiment can be applied to the synchronization between the cloud server and the terminal.
  • the network architecture for implementing the synchronization is as shown in FIG. 6, and may include: a client, a synchronization server, and a push server.
  • the synchronization server and the push server are both located in the cloud, and the two can be combined in one object.
  • the server in the embodiment of the present invention is a combination of the synchronization server and the push server in the cloud.
  • the push server may be optional.
  • the embodiment of the present invention is The so-called server refers to the synchronization server.
  • the client runs on the user terminal to synchronize between the terminal and the synchronization server.
  • the client and the sync server can communicate via the HTTP protocol.
  • the client can connect to the push server through registration to receive messages pushed by the push server.
  • the client and push server can establish a connection via HTTP or XMPP.
  • the interaction process between devices in the above network architecture is as follows: The client in the terminal first establishes a connection with the push server. When the synchronization server detects a data update, the synchronization server sends an update notification to the push server. The push server pushes the update notification to the client in the terminal. The client initiates synchronization with the synchronization server based on the update notification.
  • FIG. 7 is a schematic structural diagram of a server 700 that synchronizes with a terminal according to an embodiment of the present invention.
  • the server 700 is a device that implements a function of a cloud.
  • the server 700 can include:
  • the receiving unit 701 is configured to receive a request to move the file from the first directory to the second directory, and the identifier of the file and the identifier of the second directory in the request;
  • the processing unit 702 is configured to search for metadata of the file according to the identifier of the file received by the receiving unit 701, and change the parent directory identifier of the file to the identifier of the second directory in the metadata of the file, and at the first
  • the proxy metadata of the file is created under the directory, and the proxy metadata is used to indicate that the file has been moved to the second directory;
  • the synchronization unit 703 is configured to send the proxy metadata of the file to the terminal to perform synchronization between the server and the terminal through the file local to the terminal.
  • the request received by the receiving unit 701 carries the identifier of the file that needs to be moved and the identifier of the target directory of the file.
  • the source directory of the file to be moved is the first directory
  • the target directory is the second directory, so the request received by the server needs to carry the identifier of the second directory.
  • the identifier of the source directory of the file may or may not be carried.
  • the processing unit 702 may determine the received request as a request to perform the move operation according to the name of the request or the type of operation specified in the request.
  • the processing unit 702 changes the parent directory identifier of the file to the identifier of the second directory, it is further used to determine whether there is proxy metadata for indicating that the file has been removed from the second directory in the second directory; The proxy metadata for indicating that the file has been removed from the second directory exists under the second directory, and the proxy metadata under the second directory is deleted.
  • the synchronization unit 703 detects the update data since the last synchronization in the directory to be synchronized, and transmits the detected update data to the terminal. For example, in this embodiment, when the first directory is to be synchronized with the terminal, the synchronization unit 703 detects the update data of the first directory during the current synchronization and the last synchronization, and when determining that the update data includes the proxy metadata, The proxy metadata in a directory is sent to the terminal. When the second directory is to be synchronized, the synchronization unit 703 detects the update data of the second directory during the current synchronization and the last synchronization, and when determining that the update data includes the metadata of the file moved to the second directory, The metadata of the file is sent to the terminal.
  • the file is moved from the source directory to the destination directory by changing the parent directory of the file, and the proxy metadata is created in the source directory for the file that has been moved to the target directory, so that the terminal is in the synchronization source directory and
  • the target directory When the target directory is located, it can be recognized that the mobile operation occurs on the server side, so that the mobile terminal performs the local operation according to the mobile operation without saving the file from the server side, thereby saving network resources.
  • the present invention converts the file by changing the parent directory of the file. Moving from the source directory to the destination directory keeps the logical number of the file unchanged, so that the shared, public, and external links of the original associated file f remain valid.
  • FIG. 8 is a schematic structural diagram of a server 700 for synchronizing with a terminal according to another embodiment of the present invention.
  • the server 700 further includes: a maintenance unit 704, based on the embodiment shown in FIG. Used to delete the expired agent metadata in the server according to the preset time limit.
  • the server may further include: a notification unit 705, configured to send, to the terminal synchronized with the server, an update notification of the first directory and the second directory, so that the terminal is configured according to the The update notification initiates a request to synchronize the first directory or the second directory.
  • a notification unit 705 configured to send, to the terminal synchronized with the server, an update notification of the first directory and the second directory, so that the terminal is configured according to the The update notification initiates a request to synchronize the first directory or the second directory.
  • a terminal 900 synchronized with a server according to another embodiment of the present invention is shown in FIG.
  • the terminal 900 can include:
  • the synchronization unit 901 is configured to move the file from the first directory to the second directory by changing the parent directory identifier of the file in the metadata of the file, and create proxy metadata of the file in the first directory. After receiving the proxy metadata of the file from the server, and providing it to the processing unit 902, where the proxy metadata is used to indicate that the file has been moved to the second directory; the processing unit 902 is configured to use the proxy metadata according to the proxy metadata.
  • the metadata of the file is locally looked up, and the synchronization with the server is completed by the metadata of the file found locally.
  • the proxy metadata may include an identifier of the file, an identifier of the second directory, and a moving target Remember.
  • the mobile tag is used to indicate that the file has moved, and the target directory when the terminal receives the update data movement, that is, the current parent directory of the file.
  • the processing unit 902 is specifically configured to determine, according to the mobile tag in the proxy metadata, that the file has moved; searching for metadata of the file locally according to the identifier of the file; and searching for the file in the metadata of the file
  • the parent directory ID is changed to the ID of the second directory.
  • the synchronization unit 901 is further operable to receive metadata of the file from the server.
  • the specific structure of the processing unit 902 may be as shown in FIG. 10, and the processing unit 902 may specifically include:
  • the first operation module 9021 is configured to search for metadata of the file locally in the terminal according to the proxy metadata, and complete synchronization of the first directory in the local directory with the first directory in the server by using the metadata of the file locally found;
  • the second operation module 9022 is configured to complete synchronization of the local second directory with the second directory in the server according to the metadata of the received file.
  • the metadata of the file received by the synchronization unit 901 from the server may include an identifier of the file and an identifier of the second directory.
  • the second operation module 9022 is specifically configured to locally search for metadata of the file according to the identifier of the file in the metadata of the received file; change the parent directory identifier of the file in the found metadata of the file. The identifier for the second directory.
  • the first operation module 9021 is specifically configured to determine, according to the mobile tag in the proxy metadata, that the file has moved; to find the metadata of the file locally according to the identifier of the file in the proxy metadata; and determine the found element of the file. Whether the parent directory identifier of the file in the data is the identifier of the second directory; if the parent directory identifier of the file is not the identifier of the second directory, the found The file is set to be hidden in the metadata of the file; if the parent directory identifier of the file is the identifier of the second directory, the file is not processed.
  • the second operation module 9022 is further configured to determine a state of the second file after the metadata of the file is found, and if the second file is in a hidden state, change the second file to the metadata of the second file to Display state.
  • the terminal 900 shown in FIG. 10 may initiate a request for synchronizing the first directory to the server, or may initiate a synchronization request according to the update notification sent by the server regarding the first directory.
  • the synchronization unit 901 in the terminal 900 shown in FIG. 10 is further configured to establish a connection with the server, and after the server moves the file from the first directory to the second directory, the receiving server sends the Update notification for a directory and a second directory.
  • the server 700 in the embodiment shown in FIG. 7 and FIG. 8 can be implemented based on the hardware structure of the computer.
  • the hardware structure of the device 700 includes a memory 1101, a transceiver 1102, and processing.
  • the processor 1103, the memory 1101, and the transceiver 1102 are communicably connected by a bus 1104.
  • the memory 1101 may be a read only memory (ROM), a static storage device, a dynamic storage device, or a random access memory (RAM).
  • the memory 1101 can store instructions of the operating system and other applications as well as application data. The instructions stored in the memory 1101 are executed by the processor 1103.
  • the memory 1101 in the embodiment of the present invention can be used to store and implement the implementation shown in FIG. 7 and FIG. 8.
  • the instructions for each functional unit in the example can be used to store and implement the implementation shown in FIG. 7 and FIG. 8.
  • Transceiver 1102 is used to enable communication between device 700 and other devices.
  • the transceiver 1102 is configured to receive a message from a terminal and send a message to the terminal.
  • the processor 1103 can use a general-purpose central processing unit (CPU), a processor, an application specific integrated circuit (ASIC), or one or more integrated circuits for executing related programs.
  • CPU central processing unit
  • ASIC application specific integrated circuit
  • the processor 1103 is configured to execute the instructions in the memory 1101, and the steps in the method embodiment shown in FIG. 2 are specifically executed, and details are not described herein again.
  • Bus 1104 can include a path for communicating information between various components of synchronization device 700, such as processor 1103, memory 1101, and receiver 1102.
  • the terminal 900 in the foregoing embodiment shown in FIG. 9 and FIG. 10 can also be implemented based on the hardware structure of the computer.
  • the hardware structure of the terminal 900 includes a memory 1201, a transceiver 1202, a processor 1203, and a bus 1204. .
  • the processor 1203, the memory 1201, and the transceiver 1202 are communicatively coupled by a bus 1204.
  • the memory 1201 may be a read only memory (ROM), a static storage device, a dynamic storage device, or a random access memory (RAM).
  • the memory 1201 can store instructions of the operating system and other applications as well as application data. The instructions stored in the memory 1201 are executed by the processor 1203.
  • the memory 1201 in the embodiment of the present invention can be used to store instructions for implementing the functional units in the embodiments shown in FIG. 9 and FIG.
  • the transceiver 1202 is configured to implement communication between the terminal 900 and other devices or communication networks (such as, but not limited to, Ethernet, Radio Access Network (RAN), Wireless Local Area Network (WLAN), etc. .
  • the transceiver 1202 is configured to receive a message from a server in the cloud and send a message to a server in the cloud.
  • the processor 1203 can use a general-purpose central processing unit (CPU), a processor, an application specific integrated circuit (ASIC), or one or more integrated circuits for executing related programs.
  • CPU central processing unit
  • ASIC application specific integrated circuit
  • the processor 1203 is configured to execute the instructions in the memory 1201, and the steps in the method embodiment shown in FIG. 3 may be specifically executed, and details are not described herein again.
  • Bus 1204 can include a path for communicating information between various components of terminal 900, such as processor 1203, memory 1201, and transceiver 1202.
  • processor 1203, memory 1201, and transceiver 1202. Through the description of the above embodiments, those skilled in the art can understand that all or part of the steps of the foregoing embodiment can be implemented by a program to instruct related hardware, and the program can be stored in a computer readable manner.
  • the method when the program is executed, the method includes the steps of the foregoing method embodiment, such as: ROM/RAM, magnetic disk, optical disk, and the like.

Abstract

Disclosed are a synchronization method and device. The method comprises: a server receiving a request for moving a file from a first directory to a second directory, wherein the request carries an identification of the file and an identification of the second directory; the server searching for metadata of the file according to the identification of the file, changing an identification of a parent directory of the file into the identification of the second directory in the metadata of the file, and creating proxy metadata of the file in the first directory, wherein the proxy metadata is used for indicating that the file has been moved to the second directory; and the server sending the proxy metadata of the file to the terminal to conduct synchronization between the server and the terminal through a local file of the terminal. By applying the embodiments of the present invention, the bandwidth consumption is reduced and the synchronization efficiency is increased.

Description

一种终端与服务器进行同步的方法和装置 本申请要求 2013年 6月 29 日递交的申请号为 201310270933. 8、 发明名 称为 "一种终端与服务器进行同步的方法和装置"的中国专利申请的优先权, 其全部内容通过引用结合在本申请中。 技术领域  The invention relates to a method and a device for synchronizing a terminal with a server. The application for the application of the method and device for synchronizing the terminal and the server is disclosed in the application No. 201310270933. Priority is hereby incorporated by reference in its entirety. Technical field
本发明涉及通信技术领域, 特别涉及一种终端与服务器进行同步的方 法和装置。 背景技术  The present invention relates to the field of communications technologies, and in particular, to a method and apparatus for synchronizing a terminal with a server. Background technique
随着云技术的发展, 越来越多用户将文件保存在云端。 目前, 云端支持 手机、 个人计算机(personal computer, PC ) 、 万维网 Web等客户端实时跟 云端的文件进行同步, 在无需用户的干预下保证用户本地的数据和云端的数 据相一致, 以便用户无论何时何地都保证获取最新数据, 给用户良好体验。  With the development of cloud technology, more and more users keep files in the cloud. At present, the cloud supports mobile phones, personal computers (PCs), web pages, and other clients to synchronize with the files in the cloud in real time, ensuring that the user's local data and the cloud data are consistent without user intervention, so that the user can Whenever and wherever you are, you are guaranteed to get the latest data and give the user a good experience.
现有技术中, 典型的云端同步有两种方式: 全量式同步和增量式同步。 全量式同步是指当云端有更新, 那么客户端需要从服务器获取全量数据 到本地客户端, 然后比较本地客户端数据和从云端获取得到的数据, 获取不 一致的数据, 最后同步不一致的数据。 其中, 从云端获取全量数据需要大量 用户的流量。  In the prior art, there are two ways of typical cloud synchronization: full-size synchronization and incremental synchronization. Full-scale synchronization means that when the cloud is updated, the client needs to obtain the full amount of data from the server to the local client, and then compare the local client data with the data obtained from the cloud, obtain the inconsistent data, and finally synchronize the inconsistent data. Among them, obtaining full data from the cloud requires a large amount of user traffic.
增量式同步是指当云端有更新, 那么客户端和云端仅同步更新的数据, 无需获取全部数据。 因此可以大大减轻用户的流量。  Incremental synchronization means that when there is an update in the cloud, the client and the cloud only synchronize the updated data without obtaining all the data. Therefore, the user's traffic can be greatly reduced.
但是, 现有的增量式同步在实现移动操作时, 是通过拷贝和删除操作组 合来实现的。 如图 1所示, 云端在将 S目录下的 f文件移动到 D目录下时, 现有技术是先将文件 f复制到 D目录下, 生成新文件 f , 然后删除 S目录下 的 f文件。 其中, 云端需要为 f 重新产生一个新的文件逻辑号 (logicalFileld) (需要说明的是, 云端使用文件逻辑号, 而不是文件名作为文件的唯一标识 符, 因为文件名可以随意改名, 导致无法作为文件的唯一标识符) 。 由于云 端对于文件 f 重新产生一个新的文件逻辑号, 因此, 会导致原有关联文件 f 的共享、 公开以及外链的链接失效。 而且, 当客户端从云端同步目录 S和目 录 D时, 需要删除终端中 S目录下的 f文件, 并从云端下载文件 f 到终端的 目录 D下, 导致网络流量的浪费。 发明内容 However, existing incremental synchronization is implemented by a combination of copy and delete operations when implementing a move operation. As shown in Figure 1, when the cloud moves the f file in the S directory to the D directory, the prior art first copies the file f to the D directory, generates a new file f, and then deletes the f file in the S directory. The cloud needs to regenerate a new file logical number (logicalFileld) for f. (It should be noted that the cloud uses the file logical number instead of the file name as the unique identifier of the file, because the file name can be renamed at will, resulting in failure to act as The unique identifier of the file). Due to the cloud The end regenerates a new file logical number for the file f, thus causing the sharing, disclosure, and link of the original associated file f to be invalid. Moreover, when the client synchronizes the directory S and the directory D from the cloud, the f file in the S directory of the terminal needs to be deleted, and the file f is downloaded from the cloud to the directory D of the terminal, resulting in waste of network traffic. Summary of the invention
本发明实施例提供一种终端与服务器进行同步的方法和装置以解决 在客户端与云端同步移动操作时, 导致流量浪费以及链接失效的问题。  The embodiment of the invention provides a method and a device for synchronizing a terminal with a server to solve the problem of waste of traffic and link failure when the client and the cloud synchronize the mobile operation.
第一方面, 一种终端与服务器进行同步, 包括:  In a first aspect, a terminal synchronizes with a server, including:
服务器接收将文件从第一目录移动到第二目录的请求, 所述请求中携 带所述文件的标识和所述第二目录的标识;  The server receives a request to move the file from the first directory to the second directory, the request carrying the identifier of the file and the identifier of the second directory;
服务器根据所述文件的标识查找所述文件的元数据, 在所述文件的元 数据中将所述文件的父目录标识更改为所述第二目录的标识, 并在所述第 一目录下创建所述文件的代理元数据, 所述代理元数据用于表示所述文件 已移动到第二目录;  The server searches for metadata of the file according to the identifier of the file, and changes a parent directory identifier of the file to an identifier of the second directory in the metadata of the file, and creates the file in the first directory. Proxy metadata of the file, the proxy metadata is used to indicate that the file has been moved to a second directory;
所述服务器将所述文件的代理元数据发送给所述终端, 以通过所述终 端本地的所述文件来进行所述服务器和所述终端之间的同步。  The server sends the proxy metadata of the file to the terminal to perform synchronization between the server and the terminal through the file local to the terminal.
在第一方面的第一种可能的实现方式中, 所述代理元数据包括所述文 件的标识, 第二目录的标识以及用于表示所述文件已发生移动的移动标 记;  In a first possible implementation manner of the first aspect, the proxy metadata includes an identifier of the file, an identifier of the second directory, and a mobile label indicating that the file has moved;
所述服务器将所述文件的代理元数据发送给终端后, 所述方法还包 括:  After the server sends the proxy metadata of the file to the terminal, the method further includes:
所述终端根据所述代理元数据中的移动标记确定所述文件已发生移 动;  Determining, by the terminal, that the file has moved according to a movement flag in the proxy metadata;
根据所述文件的标识在本地查找所述文件的元数据;  Finding metadata of the file locally according to the identifier of the file;
在查找到的所述文件的元数据中将所述文件的父目录标识更改为所 述第二目录的标识。  Changing the parent directory identifier of the file to the identifier of the second directory in the metadata of the found file.
在第一方面的第二种可能的实现方式中, 所述方法还包括: 将所述文 件的元数据发送给所述终端; In a second possible implementation manner of the first aspect, the method further includes: The metadata of the piece is sent to the terminal;
所述终端根据所述文件的代理元数据更新所述终端中的第一目录, 并 根据所述文件的元数据更新所述终端中的第二目录。  The terminal updates the first directory in the terminal according to the proxy metadata of the file, and updates the second directory in the terminal according to the metadata of the file.
结合第一方面的第二种可能的实现方式, 在第三种可能的实现方式 中, 所述文件的元数据包括所述文件的标识和所述第二目录的标识;  With reference to the second possible implementation of the first aspect, in a third possible implementation, the metadata of the file includes an identifier of the file and an identifier of the second directory;
所述根据所述文件的元数据更新所述终端中的第二目录具体包括: 所述终端根据所述文件的元数据中的所述文件的标识在本地查找所 述文件的元数据;  Updating the second directory in the terminal according to the metadata of the file specifically includes: the terminal locally searching for metadata of the file according to the identifier of the file in the metadata of the file;
在查找到的所述文件的元数据中将所述文件的父目录标识更改为所 述第二目录的标识。  Changing the parent directory identifier of the file to the identifier of the second directory in the metadata of the found file.
结合第一方面的第三种可能的实现方式, 在第四种可能的实现方式 中, 所述代理元数据中包括所述文件的标识, 第二目录的标识以及用于表 示所述文件已发生移动的移动标记;  With reference to the third possible implementation manner of the first aspect, in a fourth possible implementation, the proxy metadata includes an identifier of the file, an identifier of the second directory, and is used to indicate that the file has occurred Moving move marker
所述终端根据所述文件的代理元数据更新所述终端中的第一目录具 体包括:  Updating, by the terminal, the first directory specific item in the terminal according to the proxy metadata of the file includes:
所述终端根据所述代理元数据中的移动标记确定所述文件已发生移 动;  Determining, by the terminal, that the file has moved according to a movement flag in the proxy metadata;
根据所述代理元数据中的文件的标识在本地查找所述文件的元数据; 判断查找 'J的所述文件的元数据中所述文件的父目录标识是否为所 述第二目录的标识;  Determining the metadata of the file locally according to the identifier of the file in the proxy metadata; determining whether the parent directory identifier of the file in the metadata of the file searching for 'J is an identifier of the second directory;
若所述文件的父目录标识不是所述第二目录的标识, 则在查找到的所 述文件的元数据中将所述文件设置为隐藏;  If the parent directory identifier of the file is not the identifier of the second directory, the file is set to be hidden in the metadata of the found file;
若所述文件的父目录标识是所述第二目录的标识, 则不对所述文件做 处理。  If the parent directory identifier of the file is an identifier of the second directory, the file is not processed.
结合第一方面的第四种可能的实现方式, 在第五种可能的实现方式 中, 在所述终端根据所述文件的元数据中的所述文件的标识在本地查找到 所述文件的元数据后, 所述方法还包括: 确定所述文件的状态, 若所述文 件为隐藏状态, 则在所述文件的元数据中将所述文件更改为显示状态。 结合第一方面或第一方面第一至四任一种可能的实现方式, 在第六种 可能的实现方式中, 在所述服务器根据所述文件的标识查找所述文件的元 数据后, 所述方法还进一步包括: In conjunction with the fourth possible implementation of the first aspect, in a fifth possible implementation, the terminal locally searches for the element of the file according to the identifier of the file in the metadata of the file. After the data, the method further includes: determining a state of the file, and if the file is in a hidden state, changing the file to a display state in metadata of the file. With reference to the first aspect, or any one of the first to fourth possible implementation manners of the first aspect, in a sixth possible implementation manner, after the server searches for metadata of the file according to the identifier of the file, The method further includes:
服务器判断所述第二目录下是否存在表明所述文件已从所述第二目 录移走的代理元数据;  Determining, by the server, whether there is proxy metadata indicating that the file has been removed from the second directory under the second directory;
若所述第二目录下存在用于表明所述文件已从所述第二目录移走的 代理元数据, 则删除所述代理元数据。  If there is proxy metadata for indicating that the file has been removed from the second directory under the second directory, the proxy metadata is deleted.
第二方面, 一种终端与服务器进行同步的方法, 包括:  In a second aspect, a method for synchronizing a terminal with a server includes:
在服务器通过在文件的元数据中更改所述文件的父目录标识的方式 将所述文件从第一目录移动到第二目录, 并在第一目录下创建所述文件的 代理元数据后, 终端从所述务器接收所述文件的代理元数据, 所述代理元 数据用于表示所述文件已移动到第二目录;  After the server moves the file from the first directory to the second directory by changing the parent directory identifier of the file in the metadata of the file, and creating the proxy metadata of the file in the first directory, the terminal Receiving proxy metadata of the file from the server, the proxy metadata is used to indicate that the file has been moved to a second directory;
所述终端根据所述代理元数据在终端本地查找所述文件的元数据, 通 过在本地查找到的所述文件的元数据来完成与所述服务器的同步。  The terminal searches the metadata of the file locally in the terminal according to the proxy metadata, and completes synchronization with the server by using the metadata of the file found locally.
结合第二方面的第一种可能的实现方式, 所述代理元数据包括所述文 件的标识, 第二目录的标识以及用于表示所述文件已发生移动的移动标 记;  In conjunction with the first possible implementation of the second aspect, the proxy metadata includes an identifier of the file, an identifier of the second directory, and a mobile tag indicating that the file has moved;
所述终端根据所述代理元数据在终端本地查找所述文件的元数据, 通 过在本地查找到的所述文件的元数据来完成与所述服务器的同步具体包 括:  The terminal searches the metadata of the file locally in the terminal according to the proxy metadata, and completes synchronization with the server by using the metadata of the file found locally:
所述终端根据所述代理元数据中的移动标记确定所述文件已发生移 动;  Determining, by the terminal, that the file has moved according to a movement flag in the proxy metadata;
根据所述文件的标识在本地查找所述文件的元数据;  Finding metadata of the file locally according to the identifier of the file;
在查找到的所述文件的元数据中将所述文件的父目录标识更改为所 述第二目录的标识。  Changing the parent directory identifier of the file to the identifier of the second directory in the metadata of the found file.
结合第二方面的第二种可能的实现方式, 所述通过在本地查找到的所 述文件的元数据来完成与所述服务器的同步具体包括: 通过在本地查找到 的所述文件的元数据来完成所述终端中的第一目录与所述服务器中的第 一目录的同步; With reference to the second possible implementation manner of the second aspect, the performing the synchronization with the server by using the metadata of the file that is locally found specifically includes:: metadata of the file that is found locally Completing the first directory in the terminal and the first in the server Synchronization of a directory;
所述方法还包括:  The method further includes:
所述终端从所述服务器接收所述文件的元数据;  Receiving, by the terminal, metadata of the file from the server;
所述终端根据接收到的所述文件的元数据完成所述终端中的第二目 录与所述服务器中的第二目录的同步。  The terminal completes synchronization of the second directory in the terminal with the second directory in the server according to the received metadata of the file.
结合第二方面的第二种可能的实现方式, 在第三种可能的实现方式 中, 所述从所述服务器接收的所述文件的元数据包括所述文件的标识和所 述第二目录的标识;  With reference to the second possible implementation of the second aspect, in a third possible implementation, the metadata of the file received from the server includes an identifier of the file and a second directory Identification
所述终端根据所述文件的元数据完成所述终端中的第二目录与所述 服务器中的第二目录的同步具体包括:  The synchronizing the second directory in the terminal with the second directory in the server according to the metadata of the file includes:
所述终端根据接收到的所述文件的元数据中的所述文件的标识在本 地查找所述文件的元数据;  The terminal locally searches for metadata of the file according to the identifier of the file in the received metadata of the file;
在查找到的所述文件的元数据中将所述文件的父目录标识更改为所 述第二目录的标识。  Changing the parent directory identifier of the file to the identifier of the second directory in the metadata of the found file.
结合第二方面的第三种可能的实现方式, 在第四种可能的实现方式 中, 所述代理元数据中包括所述文件的标识, 第二目录的标识以及用于表 示所述文件已发生移动的移动标记;  With reference to the third possible implementation manner of the second aspect, in a fourth possible implementation, the proxy metadata includes an identifier of the file, an identifier of the second directory, and is used to indicate that the file has occurred Moving move marker
所述终端根据所述代理元数据在终端本地查找所述文件的元数据, 通 过在本地查找到的所述文件的元数据来完成所述终端中的第一目录与所 述服务器中的第一目录的同步具体包括:  The terminal searches the metadata of the file locally in the terminal according to the proxy metadata, and completes the first directory in the terminal and the first in the server by using the metadata of the file found locally. The synchronization of the directory specifically includes:
所述终端根据所述代理元数据中的移动标记确定所述文件已发生移 动;  Determining, by the terminal, that the file has moved according to a movement flag in the proxy metadata;
根据所述代理元数据中的文件的标识在本地查找所述文件的元数据; 判断查找 'J的所述文件的元数据中所述文件的父目录标识是否为所 述第二目录的标识;  Determining the metadata of the file locally according to the identifier of the file in the proxy metadata; determining whether the parent directory identifier of the file in the metadata of the file searching for 'J is an identifier of the second directory;
若所述文件的父目录标识不是所述第二目录的标识, 则在查找到的所 述文件的元数据中将所述文件设置为隐藏;  If the parent directory identifier of the file is not the identifier of the second directory, the file is set to be hidden in the metadata of the found file;
若所述文件的父目录标识是所述第二目录的标识, 则不对所述文件做 处理。 If the parent directory identifier of the file is an identifier of the second directory, the file is not deal with.
结合第二方面的第四种可能的实现方式, 在第五种可能的实现方式 中, 在所述终端根据所述文件的元数据中的所述文件的标识在本地查找到 所述文件的元数据后, 所述方法还包括: 确定所述文件的状态, 若所述文 件为隐藏状态, 则在所述文件的元数据中将所述文件更改为显示状态。  With reference to the fourth possible implementation of the second aspect, in a fifth possible implementation, the terminal finds the element of the file locally according to the identifier of the file in the metadata of the file. After the data, the method further includes: determining a state of the file, and if the file is in a hidden state, changing the file to a display state in metadata of the file.
第三方面, 一种与终端进行同步的服务器, 所述服务器包括: 接收单元, 用于接收将文件从第一目录移动到第二目录的请求, 所述 请求中携带所述文件的标识和所述第二目录的标识;  A third aspect, a server that synchronizes with a terminal, the server includes: a receiving unit, configured to receive a request for moving a file from a first directory to a second directory, where the request carries an identifier and a location of the file The identifier of the second directory;
处理单元, 用于根据所述文件的标识查找所述文件的元数据, 在所述 文件的元数据中将所述文件的父目录标识更改为所述第二目录的标识, 并 在所述第一目录下创建所述文件的代理元数据, 所述代理元数据用于表示 所述文件已移动到所述第二目录;  a processing unit, configured to search for metadata of the file according to the identifier of the file, change a parent directory identifier of the file to an identifier of the second directory in the metadata of the file, and in the Creating a proxy metadata of the file in a directory, the proxy metadata is used to indicate that the file has been moved to the second directory;
同步单元, 用于将所述文件的代理元数据发送给终端, 以通过所述终 端本地的所述文件来进行所述服务器和所述终端之间的同步。  And a synchronization unit, configured to send proxy metadata of the file to the terminal, to perform synchronization between the server and the terminal by using the file local to the terminal.
在第三方面的第一种可能的实现方式中, 所述同步单元还用于将所述 文件的元数据发送给所述终端; 所述文件的代理元数据用以同步第一目 录, 所述文件的元数据用以同步第二目录。  In a first possible implementation manner of the third aspect, the synchronization unit is further configured to send metadata of the file to the terminal, and proxy metadata of the file is used to synchronize the first directory, where The metadata of the file is used to synchronize the second directory.
结合第三方面或第三方面的第一种可能的实现方式, 在第二种可能的 实现方式中, 所述处理单元在将所述文件的父目录标识更改为所述第二目 录的标识时, 还进一步用于判断所述第二目录下是否存在用于表示所述文 件已从所述第二目录移除的代理元数据; 若所述第二目录下存在用于指示 所述文件已从所述第二目录移除的代理元数据, 则删除所述第二目录下的 代理元数据。  With reference to the third aspect, or the first possible implementation manner of the third aspect, in a second possible implementation manner, the processing unit, when changing a parent directory identifier of the file to an identifier of the second directory And further determining whether there is proxy metadata for indicating that the file has been removed from the second directory under the second directory; if the second directory exists to indicate that the file has been The proxy metadata removed by the second directory deletes the proxy metadata under the second directory.
第四方面, 一种与服务器进行同步的终端, 包括: 同步单元, 用于在 服务器通过在文件的元数据中更改所述文件的父目录标识的方式将所述 文件从第一目录移动到第二目录, 并在第一目录下创建所述文件的代理元 数据后, 从所述服务器接收所述文件的代理元数据, 并提供给处理单元, 所述代理元数据用于表示所述文件已移动到第二目录; 所述处理单元, 用于根据所述代理元数据在终端本地查找所述文件的 元数据, 通过在本地查找到的所述文件的元数据来完成与所述服务器的同 步。 A fourth aspect, a terminal for synchronizing with a server, comprising: a synchronization unit, configured to move the file from a first directory to a first manner by changing a parent directory identifier of the file in metadata of a file After the second directory, and the proxy metadata of the file is created in the first directory, the proxy metadata of the file is received from the server and provided to the processing unit, where the proxy metadata is used to indicate that the file has been Move to the second directory; The processing unit is configured to search for metadata of the file locally in the terminal according to the proxy metadata, and complete synchronization with the server by using metadata of the file found locally.
在第四方面的第一种可能的实现方式中, 所述代理元数据包括所述第 一文件的标识, 所述第二目录的标识以及用于指示所述文件已发生移动的 移动标记; 文件已发生移动; 根据所述文件的标识在本地查找所述文件的元数据; 在 查找到的所述文件的元数据中将所述文件的父目录标识更改为所述第二 目录的标识。  In a first possible implementation manner of the fourth aspect, the proxy metadata includes an identifier of the first file, an identifier of the second directory, and a mobile tag used to indicate that the file has moved; The movement has occurred; the metadata of the file is locally searched according to the identifier of the file; the parent directory identifier of the file is changed to the identifier of the second directory in the found metadata of the file.
在第四方面的第二种可能的实现方式中, 所述同步单元还用于从所述 服务器接收所述文件的元数据;  In a second possible implementation manner of the fourth aspect, the synchronization unit is further configured to receive metadata of the file from the server;
所述处理单元具体包括:  The processing unit specifically includes:
第一操作模块, 用于根据所述代理元数据在终端本地查找所述文件的 元数据, 通过在本地查找到的所述文件的元数据来完成本地的第一目录与 所述服务器中的第一目录的同步;  a first operation module, configured to search for metadata of the file locally in the terminal according to the proxy metadata, and complete the local first directory and the first in the server by using the metadata of the file locally found Synchronization of a directory;
第二操作模块, 用于根据接收到的所述文件的元数据完成本地的第二 目录与所述服务器中的第二目录的同步。  And a second operation module, configured to complete synchronization of the local second directory with the second directory in the server according to the received metadata of the file.
结合第四方面的第二种可能的实现方式, 在第三种可能的实现方式 中, 所述从所述服务器接收的所述文件的元数据包括所述文件的标识和所 述第二目录的标识;  With reference to the second possible implementation of the fourth aspect, in a third possible implementation, the metadata of the file received from the server includes an identifier of the file and a second directory Identification
所述第二操作模块具体用于根据接收到的所述文件的元数据中的所 述文件的标识在本地查找所述文件的元数据; 在查找到的所述文件的元数 据中将所述文件的父目录标识更改为所述第二目录的标识。  The second operation module is specifically configured to locally search for metadata of the file according to the identifier of the file in the metadata of the received file, where the metadata of the file is found The parent directory ID of the file is changed to the identity of the second directory.
结合第四方面的第三种可能的实现方式, 在第四种可能的实现方式 中, 所述代理元数据中包括所述文件的标识, 第二目录的标识以及用于表 示所述文件已发生移动的移动标记;  With reference to the third possible implementation manner of the fourth aspect, in a fourth possible implementation, the proxy metadata includes an identifier of the file, an identifier of the second directory, and is used to indicate that the file has occurred Moving move marker
所述第一操作模块具体用于根据所述代理元数据中的移动标记确定 所述文件已发生移动; 根据所述代理元数据中的文件的标识在本地查找所 述文件的元数据; 判断查找到的所述文件的元数据中所述文件的父目录标 识是否为所述第二目录的标识; 若所述文件的父目录标识不是所述第二目 录的标识, 则在查找到的所述文件的元数据中将所述文件设置为隐藏; 若 所述文件的父目录标识是所述第二目录的标识, 则不对所述文件做处理。 The first operation module is specifically configured to determine, according to the mobile tag in the proxy metadata The file has been moved; the metadata of the file is locally searched according to the identifier of the file in the proxy metadata; determining whether the parent directory identifier of the file in the metadata of the found file is the An identifier of the second directory; if the parent directory identifier of the file is not the identifier of the second directory, the file is set to be hidden in the metadata of the found file; if the parent directory of the file The identifier is an identifier of the second directory, and the file is not processed.
结合第四方面的第三种可能的实现方式, 在第四种可能的实现方式 中, 所述第二操作模块还用于在查找到所述文件的元数据后, 确定所述文 件的状态, 若所述文件处于隐藏状态, 则在所述文件的元数据中将所述文 件更改为显示状态。  With reference to the third possible implementation manner of the fourth aspect, in a fourth possible implementation, the second operating module is further configured to determine a state of the file after the metadata of the file is found, If the file is in a hidden state, the file is changed to a display state in the metadata of the file.
本发明实施例中,服务器通过更改文件的父目录的方式将文件从源目 录移动到目的目录, 并在源目录下为已移动到目标目录的文件创建代理元 数据, 使得终端在同步源目录和目标目录时, 可以识别出服务器侧发生的 是移动操作, 从而利用终端本地的文件来实现与服务器的同步, 而无需从 服务器侧重新下载文件, 节约了网络资源。 而且本发明通过更改文件的父 目录的方式将文件从源目录移动到目的目录, 使得文件的逻辑号保持不 变,从而可以保持原有关联文件 f的共享、公开以及外链的链接仍然有效。 附图说明  In the embodiment of the present invention, the server moves the file from the source directory to the destination directory by changing the parent directory of the file, and creates proxy metadata for the file that has been moved to the target directory in the source directory, so that the terminal is in the synchronization source directory and In the target directory, it can be recognized that the mobile side operates on the server side, so that the local file is used to synchronize with the server without re-downloading the file from the server side, thereby saving network resources. Moreover, the present invention moves the file from the source directory to the destination directory by changing the parent directory of the file, so that the logical number of the file remains unchanged, so that the shared, public, and external links of the original associated file f can remain valid. DRAWINGS
为了更清楚地说明本发明实施例的技术方案, 下面将对实施例中所需 要使用的附图作简单地介绍, 显而易见地, 下面描述中的附图仅仅是本发 明的一些实施例, 对于本领域普通技术人员来讲, 在不付出创造性劳动的 前提下, 还可以根据这些附图获得其他的附图。  In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the drawings used in the embodiments will be briefly described below. It is obvious that the drawings in the following description are only some embodiments of the present invention. One of ordinary skill in the art can also obtain other drawings based on these drawings without undue creative effort.
图 1是现有技术中的同步方法的流程图;  1 is a flow chart of a synchronization method in the prior art;
图 2是本发明实施例提供的终端与服务器进行同步方法的流程图; 图 3 是本发明另一实施例提供的终端与服务器进行同步方法的流程 图; 图 5是本发明实施例提供的文件 f的移动示意图; 图 6是本发明实施例提供的网络架构示意图; 2 is a flowchart of a method for synchronizing a terminal and a server according to an embodiment of the present invention; FIG. 3 is a flowchart of a method for synchronizing a terminal and a server according to another embodiment of the present invention; FIG. a schematic diagram of the movement of f; FIG. 6 is a schematic diagram of a network architecture according to an embodiment of the present invention;
图 7是本发明实施例提供的与终端进行同步的服务器的结构示意图; 图 8是本发明另一实施例提供的与终端进行同步的服务器的结构示意 图;  7 is a schematic structural diagram of a server that synchronizes with a terminal according to an embodiment of the present invention; FIG. 8 is a schematic structural diagram of a server that synchronizes with a terminal according to another embodiment of the present invention;
图 9是本发明另一实施例提供的与服务器进行同步的终端的结构示意 图;  FIG. 9 is a schematic structural diagram of a terminal synchronized with a server according to another embodiment of the present invention; FIG.
图 10 是本发明另一实施例提供的与服务器进行同步的终端的结构示 意图;  FIG. 10 is a schematic structural diagram of a terminal synchronized with a server according to another embodiment of the present invention; FIG.
图 1 1 是本发明实施例提供的与终端进行同步的服务器的硬件结构示 意图;  FIG. 11 is a schematic diagram showing the hardware structure of a server synchronized with a terminal according to an embodiment of the present invention;
图 12 是本发明另一实施例提供的与服务器进行同步的终端的硬件结 构示意图。 具体实施方式  FIG. 12 is a schematic diagram showing the hardware structure of a terminal synchronized with a server according to another embodiment of the present invention. detailed description
下面将结合本发明实施例中的附图, 对本发明实施例中的技术方案进 行清楚、 完整地描述,显然, 所描述的实施例仅仅是本发明一部分实施例, 而不是全部的实施例。 基于本发明中的实施例, 本领域普通技术人员在没 有作出创造性劳动前提下所获得的所有其他实施例, 都属于本发明保护的 范围。  The technical solutions in the embodiments of the present invention are clearly and completely described in the following with reference to the drawings in the embodiments of the present invention. It is obvious that the described embodiments are only a part of the embodiments of the present invention, and not all of the embodiments. All other embodiments obtained by a person of ordinary skill in the art based on the embodiments of the present invention without creative efforts are within the scope of the present invention.
图 2为本发明实施例提供的终端与服务器进行同步方法的流程图, 具 体包括:  FIG. 2 is a flowchart of a method for synchronizing a terminal and a server according to an embodiment of the present invention, where the method includes:
S200 , 服务器接收将文件从第一目录移动到第二目录的请求, 该请求 中携带该文件的标识和第二目录的标识。 其中, 服务器可以是云同步服务器, 用于提供云同步服务, 实现在用 户的多个终端上同步文件。 在用户与服务器同步的多个终端中, 若其中一个终端中的文件从第一 目录移动到了第二目录, 则该终端会向服务器发起将文件从第一目录移动 到第二目录的请求, 以使服务器根据该请求执行移动操作, 并通过服务器 同步用户的其它终端。 S200. The server receives a request for moving a file from a first directory to a second directory, where the request carries an identifier of the file and an identifier of the second directory. The server may be a cloud synchronization server, configured to provide a cloud synchronization service, and synchronize files on multiple terminals of the user. In a plurality of terminals synchronized by the user and the server, if the file in one of the terminals moves from the first directory to the second directory, the terminal initiates a request to move the file from the first directory to the second directory to the server, to Causes the server to perform a move operation based on the request and synchronize the user's other terminals through the server.
可选的, 步骤 S200中的请求也可以由用户通过 Web客户端向服务器 发送, 使服务器根据该请求执行移动操作后, 再从服务器同步到用户的所 有或部分终端中。  Optionally, the request in step S200 may also be sent by the user to the server through the web client, so that the server performs the mobile operation according to the request, and then synchronizes from the server to all or part of the user's terminal.
其中, 服务器接收到的请求中要携带需要移动的文件的标识以及该文 件的目标目录的标识。在本实施例中,要移动的文件的源目录为第一目录, 目标目录为第二目录, 因此服务器接收到的请求中需要携带第二目录的标 识。 对于文件的源目录的标识则可以携带, 也可以不携带。  The request received by the server carries the identifier of the file to be moved and the identifier of the target directory of the file. In this embodiment, the source directory of the file to be moved is the first directory, and the target directory is the second directory, so the request received by the server needs to carry the identifier of the second directory. The identifier of the source directory of the file may or may not be carried.
S202 , 服务器根据请求中携带的文件的标识查找该文件的元数据, 在 该文件的元数据中将该文件的父目录标识更改为第二目录的标识, 并在第 一目录下创建该文件的代理元数据, 其中, 代理元数据用于表示该文件已 移动到第二目录。  S202. The server searches for metadata of the file according to the identifier of the file carried in the request, changes the parent directory identifier of the file to the identifier of the second directory in the metadata of the file, and creates the file in the first directory. The proxy metadata, where the proxy metadata is used to indicate that the file has been moved to the second directory.
服务器在识别出接收到的请求为执行移动操作的请求后, 执行步骤 S202的操作。 其中, 服务器可以根据请求的名称或者请求中指定的操作类 型来确定接收到的请求为执行移动操作的请求。 该请求可以釆用现有技术 中的移动操作请求, 这里不再赘述。  After the server recognizes that the received request is a request to perform a move operation, the server performs the operation of step S202. The server may determine the received request as a request to perform a move operation according to the name of the request or the type of operation specified in the request. The request can use the mobile operation request in the prior art, and will not be described here.
需要说明的是, 文件的属性通常是通过文件的元数据来定义。 比如, 文件和目录的归属关系, 可以由文件的元数据中的父目录项来定义。  It should be noted that the attributes of a file are usually defined by the metadata of the file. For example, the ownership of files and directories can be defined by the parent directory entry in the metadata of the file.
本发明实施例中, 服务器在接收到将文件移动第二目录的请求后, 可 以根据请求中携带的文件标识查找与该文件标识对应的文件的元数据, 并 在该文件的元数据中将该文件的父目录标识更改为第二目录的标识。 另 外, 服务器还需要在该文件的源目录(即第一目录下)为该文件创建代理 元数据, 以在与终端同步第一目录时, 通过代理元数据指示终端该文件已 移动到第二目录。 其中, 文件的代理元数据可以由文件的元数据加移动标 记构成, 或者由文件的元数据中的部分数据加移动标记构成。 其中, 移动 标记用于指示该文件已发生移动。 通常情况下, 文件的元数据可以包括文 件的标识, 文件的父目录标识等属性。 本实施例中, 由于文件已经移动到 目标目录(即第二目录) , 因此该文件的代理元数据可以包括该文件的标 识, 第二目录的标识以及移动标记。 In the embodiment of the present invention, after receiving the request to move the file to the second directory, the server may The metadata of the file corresponding to the file identifier is searched according to the file identifier carried in the request, and the parent directory identifier of the file is changed to the identifier of the second directory in the metadata of the file. In addition, the server also needs to create proxy metadata for the file in the source directory of the file (ie, under the first directory) to indicate that the file has been moved to the second directory by the proxy metadata when the first directory is synchronized with the terminal. . The proxy metadata of the file may be composed of the metadata of the file plus the mobile tag, or the partial data in the metadata of the file plus the mobile tag. Wherein, the move marker is used to indicate that the file has moved. In general, the metadata of a file can include attributes such as the identifier of the file, the parent directory identifier of the file, and so on. In this embodiment, since the file has been moved to the target directory (ie, the second directory), the proxy metadata of the file may include the identifier of the file, the identifier of the second directory, and the mobile tag.
S204 , 服务器将文件的代理元数据发送给终端, 以通过终端本地的该 文件来进行服务器和终端之间的同步。  S204. The server sends the proxy metadata of the file to the terminal, so as to synchronize between the server and the terminal through the file local to the terminal.
需要说明的是, 本发明实施例中的同步可以是完全同步, 也可以是部 分同步, 终端和服务器可以分别针对第一目录和第二目录进行同步。 服务 器在确定要同步的目录后, 检测要同步的目录中自上次同步后的更新数 据, 将检测到的更新数据发送给终端。 比如, 本实施例, 服务器和终端同 步第一目录时, 服务器检测第一目录在本次同步与上次同步期间的更新数 据, 在确定该更新数据包括文件的代理元数据时, 则将第一目录下的文件 的代理元数据发送给终端。  It should be noted that the synchronization in the embodiment of the present invention may be full synchronization or partial synchronization, and the terminal and the server may synchronize the first directory and the second directory respectively. After determining the directory to be synchronized, the server detects the update data from the last synchronization in the directory to be synchronized, and transmits the detected update data to the terminal. For example, in this embodiment, when the server and the terminal synchronize the first directory, the server detects the update data of the first directory during the current synchronization and the last synchronization, and when determining that the update data includes the proxy metadata of the file, the first The proxy metadata of the file under the directory is sent to the terminal.
终端在接收到服务器返回的代理元数据后, 可以根据该代理元数据中 的移动标记获知接收到的数据为文件的代理元数据, 然后根据该代理元数 据更新本地的文件, 以完成与服务器之间的同步。 需要说明的是, 服务器与终端之间的同步可以由终端发起。 服务器可 以根据终端发送的同步请求来确定需要同步的目录。 After receiving the proxy metadata returned by the server, the terminal may learn the received metadata as the proxy metadata of the file according to the mobile tag in the proxy metadata, and then update the local file according to the proxy metadata to complete the server. Synchronization between. It should be noted that the synchronization between the server and the terminal can be initiated by the terminal. The server can determine the directory to be synchronized according to the synchronization request sent by the terminal.
本发明实施例通过更改文件的父目录的方式将文件从第一目录移动 到第二目录, 并在第一目录下为已移动到第二目录的文件创建代理元数 据, 使得终端在同步第一目录时, 可以将表示文件发生移动的代理元数据 发送给终端, 终端可以通过该代理元数据识别出服务器侧发生的是移动操 作, 从而通过终端本地的文件来完成与服务器的同步, 而无需从服务器侧 重新下载文件, 节约了网络资源。 而且本发明通过更改文件的父目录的方 式将文件从源目录移动到目的目录, 使得文件的逻辑号保持不变, 从而可 以保持原有关联文件 f 的共享、 公开以及外链的链接仍然有效。  The embodiment of the present invention moves the file from the first directory to the second directory by changing the parent directory of the file, and creates proxy metadata for the file that has been moved to the second directory in the first directory, so that the terminal is synchronized first. When the directory is used, the agent metadata indicating that the file is moved may be sent to the terminal, and the terminal may identify, by the agent metadata, that a mobile operation occurs on the server side, thereby completing synchronization with the server through the file local to the terminal, without The server side re-downloads files, saving network resources. Moreover, the present invention moves the file from the source directory to the destination directory by changing the parent directory of the file, so that the logical number of the file remains unchanged, so that the shared, public, and external links of the original associated file f remain valid.
在本发明一个实施例中, 终端在接收到服务器发送的代理元数据后可 以进行如下处理: 终端根据代理元数据中的移动标记确定该文件已发生移 动; 根据代理元数据中携带的文件标识在本地查找该文件的元数据; 在查 找到的该文件的元数据中将该文件的父目录标识更改为所述第二目录的 标识。  In an embodiment of the present invention, after receiving the proxy metadata sent by the server, the terminal may perform the following processing: the terminal determines, according to the mobile tag in the proxy metadata, that the file has moved; according to the file identifier carried in the proxy metadata. Find the metadata of the file locally; change the parent directory identifier of the file to the identifier of the second directory in the metadata of the file found.
在上述实施例中, 终端通过在本地找到与代理元数据对应的文件, 直 接将该文件的父目录更改为第二目录, 从而在终端本地实现了文件在目录 间的移动, 而无需从服务器下载文件, 却又能与服务器保持同步。  In the above embodiment, the terminal directly changes the parent directory of the file to the second directory by locally finding the file corresponding to the proxy metadata, so that the file is locally moved between the directories without downloading from the server. Files, but still synchronized with the server.
上述实施例描述了在服务器将文件从第一目录移动到第二目录后, 终 端在与服务器同步第一目录的过程中, 完成文件移动操作的同步过程。  The above embodiment describes the synchronization process of completing the file moving operation in the process of the terminal synchronizing the first directory with the server after the server moves the file from the first directory to the second directory.
在本发明的另一实施例中, 终端可以根据文件的代理元数据来更新终 端中的第一目录, 也可以在对第二目录的同步过程中更新第二目录。 具体 的, 本实施例在图 2所示实施例的基础上, 可以进一步包括: 服务器将该 文件的元数据发送给终端; 终端根据该文件的代理元数据更新终端中的第 一目录, 并根据该文件的元数据更新终端中的第二目录。 In another embodiment of the present invention, the terminal may update the first directory in the terminal according to the proxy metadata of the file, or update the second directory during the synchronization process on the second directory. Specific On the basis of the embodiment shown in FIG. 2, the embodiment may further include: the server transmitting the metadata of the file to the terminal; the terminal updating the first directory in the terminal according to the proxy metadata of the file, and according to the The metadata of the file updates the second directory in the terminal.
其中, 终端与服务器在同步第二目录时, 服务器检测第二目录在本次 同步与上次同步期间的更新数据, 在确定该更新数据包括有被移动到第二 目录的文件的元数据时, 将该文件的元数据发送给终端。  When the terminal and the server synchronize the second directory, the server detects the update data of the second directory during the current synchronization and the last synchronization, and when determining that the update data includes the metadata of the file moved to the second directory, The metadata of the file is sent to the terminal.
文件的元数据可以包括该文件的标识和第二目录的标识。 终端根据文 件的元数据更新终端中的第二目录具体可以包括: 终端根据服务器发送的 文件的元数据中携带的文件的标识在本地查找该文件的元数据; 在查找到 的该文件的元数据中将该文件的父目录标识更改为接收到的文件的元数 据中携带的第二目录的标识。  The metadata of the file may include an identification of the file and an identification of the second directory. The updating, by the terminal, the second directory in the terminal according to the metadata of the file may include: the terminal locally searching for metadata of the file according to the identifier of the file carried in the metadata of the file sent by the server; and finding the metadata of the file in the file. Change the parent directory ID of the file to the ID of the second directory carried in the metadata of the received file.
终端根据文件的代理元数据更新终端中的第一目录具体可以包括: 终 端根据代理元数据中携带的文件标识在本地查找该文件的元数据; 判断查 找到的文件的元数据中该文件的父目录标识是否为代理元数据中携带的 第二目录的标识; 若该文件的父目录标识不是第二目录的标识, 则在查找 到的文件的元数据中将该文件设置为隐藏; 若该文件的父目录标识为第二 目录的标识, 则不对该文件 #文处理。  The updating, by the terminal, the first directory in the terminal according to the proxy metadata of the file may include: the terminal locally searching for metadata of the file according to the file identifier carried in the proxy metadata; determining the parent of the file in the metadata of the found file. Whether the directory identifier is the identifier of the second directory carried in the proxy metadata; if the parent directory identifier of the file is not the identifier of the second directory, the file is set to be hidden in the metadata of the found file; if the file The parent directory identifier is the identifier of the second directory, and the file is not processed.
在具体实施时, 终端可能先发起对第一目录的同步, 也有可能先发起 对第二目录的同步。 当终端先同步第一目录时, 如果终端根据服务器返回 的代理元数据确定第一目录下有文件移动到了第二目录中, 此时, 终端可 以直接通过更改该文件的元数据中父目录将该文件移动到第二目录, 也可 以将第一目录下的该文件设置为隐藏, 而不删除该文件。 其中, 将该文件 设置为隐藏, 是为了提高用户体验, 以免在终端还未同步第二目录时, 就 更改终端中的第二目录。 而且将文件设置为隐藏, 不仅可以使终端在同步 第二目录时还可以找到该文件, 而不用从服务器重新下载该文件。 而且, 在用户看来, 终端的第一目录与服务器的第一目录下的文件也能保持一 致。 In a specific implementation, the terminal may first initiate synchronization of the first directory, and may also initiate synchronization of the second directory. When the terminal first synchronizes the first directory, if the terminal determines that the file in the first directory is moved to the second directory according to the proxy metadata returned by the server, the terminal may directly change the parent directory in the metadata of the file. The file is moved to the second directory, and the file in the first directory can also be set to be hidden without deleting the file. Among them, the file Set to hidden, in order to improve the user experience, so as not to change the second directory in the terminal when the terminal has not synchronized the second directory. Moreover, setting the file to be hidden can not only enable the terminal to find the file when synchronizing the second directory, but also without re-downloading the file from the server. Moreover, in the user's view, the first directory of the terminal and the file in the first directory of the server can also be consistent.
需要说明的是, 如果终端根据在同步第一目录时是釆用更改文件的父 目录的方式, 该操作与同步第二目录时的操作不冲突, 只是在该文件的元 数据中执行了两次同样的操作。 当然, 为了减少重复操作, 在同步第一目 录或第二目录时都可以先判断文件的父目录是否已更改为第二目录, 如果 已更改则无需再执行更改的操作。  It should be noted that, if the terminal uses the method of changing the parent directory of the file when synchronizing the first directory, the operation does not conflict with the operation when the second directory is synchronized, but is executed twice in the metadata of the file. The same operation. Of course, in order to reduce duplication, when synchronizing the first directory or the second directory, it is possible to first determine whether the parent directory of the file has been changed to the second directory, and if it has been changed, there is no need to perform the changed operation.
如果终端在同步第一目录时釆用将文件设置为隐藏的方式, 则终端在 同步第二目录时还可以进一步包括以下步骤: 终端在查找需同步的文件的 元数据后, 确定该文件的状态, 若该文件为隐藏状态, 则还进一步在该文 件的元数据中将该文件更改为显示状态。  If the terminal uses the method of setting the file to be hidden when the first directory is synchronized, the terminal may further include the following steps when synchronizing the second directory: after the terminal searches for metadata of the file to be synchronized, the terminal determines the status of the file. If the file is hidden, the file is further changed to the display state in the metadata of the file.
在本发明实施例中, 通过更改文件的父目录的方式将文件从源目录移 动到目的目录, 并在源目录下为已移动到目标目录的文件创建代理元数 据, 使得终端在同步源目录和目标目录时, 可以识别出服务器侧发生的是 移动操作, 从而在终端本地按移动操作执行, 而无需从服务器侧重新下载 文件, 节约了网络资源。 而且本发明通过更改文件的父目录的方式将文件 从源目录移动到目的目录, 使得文件的逻辑号保持不变, 从而可以保持原 有关联文件 f 的共享、 公开以及外链的链接仍然有效。  In the embodiment of the present invention, the file is moved from the source directory to the destination directory by changing the parent directory of the file, and the proxy metadata is created in the source directory for the file that has been moved to the target directory, so that the terminal is in the synchronization source directory and When the target directory is located, it can be recognized that the mobile operation occurs on the server side, so that the mobile terminal performs the local operation according to the mobile operation without saving the file from the server side, thereby saving network resources. Moreover, the present invention moves the file from the source directory to the destination directory by changing the parent directory of the file, so that the logical number of the file remains unchanged, so that the shared, public, and external links of the original associated file f can remain valid.
在具体实现本发明实施例所提供的方案时, 有可能存在以下情况: 用 户先将文件 f 从 S目录移动到 D目录, 然后又将文件 f 从 D目录移动回 S 目录。 在这种情况下, 如果按照本发明实施例提供的方案, 当再次将文件 f 从 D目录移动回 S 目录时, S 目录下已存在有文件 f 的代理元数据, 这 种情况下该代理元数据已没有必要存在。因此,在本发明的另一实施例中, 步骤 S 102中的服务器在将文件的父目录标识更改为第二目录的标识时, 还可以进一步包括以下处理: 判断第二目录下是否存在用于指示该文件已 从第二目录移除的代理元数据; 若第二目录下存在用于指示该文件已从第 二目录移除的代理元数据, 则删除该代理元数据。 When the solution provided by the embodiment of the present invention is specifically implemented, the following may exist: The user first moves the file f from the S directory to the D directory, and then moves the file f from the D directory back to the S directory. In this case, according to the solution provided by the embodiment of the present invention, when the file f is moved from the D directory back to the S directory again, the proxy metadata of the file f already exists under the S directory, in which case the proxy element Data is no longer necessary. Therefore, in another embodiment of the present invention, when the server in step S102 changes the parent directory identifier of the file to the identifier of the second directory, the server may further include the following processing: determining whether the second directory exists for The proxy metadata indicating that the file has been removed from the second directory; if there is proxy metadata indicating that the file has been removed from the second directory under the second directory, the proxy metadata is deleted.
另外, 为了节约存储资源, 在本发明的另一实施例中, 服务器还可以 定期清除代理元数据。 具体的, 服务器可以为代理元数据设置时限, 服务 器根据预设时限, 删除服务器中超期的代理元数据。  In addition, in order to save storage resources, in another embodiment of the present invention, the server may also periodically clear the proxy metadata. Specifically, the server may set a time limit for the proxy metadata, and the server deletes the expired proxy metadata in the server according to the preset time limit.
在另一可能的实施例中, 服务器在发生数据更新之后, 还可以向与服 务器同步的终端发送更新通知, 即, 在步骤 S202之后还可以进一步包括: 向与服务器同步的终端发送第一目录和第二目录的更新通知, 以便该终端 根据该更新通知发起同步第一目录或第二目录的请求。  In another possible embodiment, after the data update occurs, the server may further send an update notification to the terminal that is synchronized with the server, that is, after step S202, the method may further include: sending the first directory and the terminal synchronized with the server. An update notification of the second directory, so that the terminal initiates a request to synchronize the first directory or the second directory according to the update notification.
其中, 与服务器同步的终端是指用户在服务器注册过, 并与服务器建 立了连接的终端。 这里的用户是指被更新的文件所属的用户。 需要说明的 是, 如果在步骤 S200中是由用户的其中一个终端发生文件移动而想服务 器发起将文件从第一目录移动到第二目录的请求, 服务器在发送更新通知 时可以不向发起该请求的终端发送更新通知。  The terminal synchronized with the server refers to the terminal that the user has registered with the server and established a connection with the server. The user here refers to the user to which the updated file belongs. It should be noted that if the server initiates a request to move the file from the first directory to the second directory by one of the user's terminals in step S200, the server may not initiate the request when sending the update notification. The terminal sends an update notification.
下面从终端侧对本发明实施例做更进一步的说明, 如图 3所示, 图 3 为本发明另一实施例提供的一种同步的方法的流程图, 该方法包括: S 300 , 在服务器通过在文件的元数据中更改所述文件的父目录标识的 方式将所述文件从第一目录移动到第二目录, 并在第一目录下创建所述文 件的代理元数据后, 终端从服务器接收服务器创建在第一目录下的文件的 代理元数据, 该代理元数据用于表示该文件已移动到第二目录。 The embodiment of the present invention is further described from the terminal side. As shown in FIG. 3, FIG. 3 is a flowchart of a method for synchronizing according to another embodiment of the present invention, where the method includes: S300, moving the file from the first directory to the second directory by changing a parent directory identifier of the file in metadata of the file, and creating proxy metadata of the file in the first directory After that, the terminal receives the proxy metadata of the file created by the server in the first directory from the server, and the proxy metadata is used to indicate that the file has been moved to the second directory.
在服务器将文件从第一目录移动到第二目录后, 服务器会在第一目录 下创建该文件的代理元数据。 当服务器与终端进行第一目录的同步时, 检 测第一目录下自上次同步后的更新数据。 由于在本次同步和上次同步之 间, 第一目录下新增了文件的代理元数据。 服务器在检测更新数据时, 会 检测到该文件的代理元数据, 并把该文件的代理元数据作为更新数据发送 给终端。  After the server moves the file from the first directory to the second directory, the server creates the proxy metadata for the file in the first directory. When the server synchronizes with the terminal for the first directory, the update data of the first directory since the last synchronization is detected. Because the proxy metadata for the file is added to the first directory between this synchronization and the last synchronization. When the server detects the update data, it detects the proxy metadata of the file and sends the proxy metadata of the file as update data to the terminal.
S 302 , 终端根据该代理元数据在终端本地查找该文件的元数据, 通过 在本地查找到的文件的元数据来完成与服务器的同步。  S302. The terminal searches for metadata of the file locally in the terminal according to the proxy metadata, and completes synchronization with the server by using metadata of the file found locally.
其中, 代理元数据可以包括文件的标识, 第二目录的标识以及移动标 记。 其中, 移动标记用于表示文件已发生移动, 终端在接收到更新数据后, 时的目标目录, 即文件当前的父目录。  The proxy metadata may include an identifier of the file, an identifier of the second directory, and a mobile tag. The mobile tag is used to indicate that the file has moved, and the target directory after the terminal receives the update data, that is, the current parent directory of the file.
具体的, 终端根据代理元数据在终端本地查找文件的元数据, 通过在 本地查找到的该文件的元数据来完成与服务器的同步具体可包括: 终端根 据代理元数据中的移动标记确定该文件已发生移动; 根据该文件的标识在 本地查找该文件的元数据, 在查找到的该文件的元数据中将该文件的父目 录标识更改为第二目录的标识。  Specifically, the terminal searches the metadata of the file locally in the terminal according to the proxy metadata, and completes synchronization with the server by using the metadata of the file found locally. The method may include: determining, by the terminal, the file according to the mobile tag in the proxy metadata. The movement has occurred; the metadata of the file is found locally according to the identifier of the file, and the parent directory identifier of the file is changed to the identifier of the second directory in the metadata of the file found.
上述实施例描述了在服务器将文件从第一目录移动到第二目录后, 终 端在与服务器同步第一目录的过程中, 完成文件移动操作的同步过程。 在本发明的另一实施例中, 终端接收到文件的代理元数据后, 终端可 以仅根据该代理元数据更新终端中的第一目录, 在对第二目录的同步过程 中再更新第二目录。 具体的, 步骤 302中的通过在本地查找到的所述文件 的元数据来完成与所述服务器的同步具体可包括: 通过在本地查找到的所 述文件的元数据来完成所述终端中的第一目录与所述服务器中的第一目 录的同步。 本实施例在图 3所示实施例的基础上, 可以进一步包括: 终端 从服务器接收文件的元数据, 终端根据接收到的该文件的元数据完成终端 中的第二目录与服务器中的第二目录的同步。 The above embodiment describes that after the server moves the file from the first directory to the second directory, In the process of synchronizing the first directory with the server, the synchronization process of the file moving operation is completed. In another embodiment of the present invention, after the terminal receives the proxy metadata of the file, the terminal may update the first directory in the terminal only according to the proxy metadata, and update the second directory during the synchronization process of the second directory. . Specifically, the step of completing the synchronization with the server by using the metadata of the file that is locally found in step 302 may include: completing the metadata in the terminal by using the metadata of the file that is locally found. The first directory is synchronized with the first directory in the server. On the basis of the embodiment shown in FIG. 3, the embodiment may further include: the terminal receiving metadata of the file from the server, and the terminal completing the second directory in the terminal and the second in the server according to the received metadata of the file. Synchronization of the directory.
其中, 终端与服务器在同步第二目录时, 服务器检测第二目录在本次 同步与上次同步期间的更新数据, 在确定该更新数据包括有被移动到第二 目录的文件的元数据时, 将该文件的元数据发送给终端。  When the terminal and the server synchronize the second directory, the server detects the update data of the second directory during the current synchronization and the last synchronization, and when determining that the update data includes the metadata of the file moved to the second directory, The metadata of the file is sent to the terminal.
文件的元数据可以包括该文件的标识和第二目录的标识。 终端根据接 收到的该文件的元数据完成终端中的第二目录与服务器中的第二目录的 同步具体可以包括: 终端根据接收到的文件的元数据中携带的文件的标识 在本地查找该文件的元数据; 在查找到的该文件的元数据中将该文件的父 目录标识更改为接收到的文件的元数据中携带的第二目录的标识。  The metadata of the file may include an identification of the file and an identification of the second directory. The terminal may complete the synchronization of the second directory in the terminal with the second directory in the server according to the received metadata of the file. The terminal may include: searching, by the terminal, the file according to the identifier of the file carried in the metadata of the received file. Metadata; in the metadata of the file found, the parent directory identifier of the file is changed to the identifier of the second directory carried in the metadata of the received file.
文件的代理元数据中可以包括所述文件的标识, 第二目录的标识以及 用于表示该文件已发生移动的移动标记。 终端根据文件的代理元数据在终 端本地查找该文件的元数据, 通过在本地查找到的该文件的元数据来完成 终端中的第一目录与服务器中的第一目录的同步具体可以包括: 终端根据 代理元数据中携带的文件标识在本地查找该文件的元数据; 判断查找到的 文件的元数据中该文件的父目录标识是否为代理元数据中携带的第二目 录的标识; 若该文件的父目录标识不是第二目录的标识, 则在查找到的文 件的元数据中将该文件设置为隐藏; 若该文件的父目录标识为第二目录的 标识, 则不对该文件 #文处理。 The agent metadata of the file may include an identification of the file, an identification of the second directory, and a mobile tag indicating that the file has moved. The terminal searches for the metadata of the file in the terminal according to the proxy metadata of the file, and completes the synchronization between the first directory in the terminal and the first directory in the server by using the metadata of the file found locally. The terminal may specifically include: Finding the metadata of the file locally according to the file identifier carried in the proxy metadata; determining the found In the metadata of the file, the parent directory identifier of the file is the identifier of the second directory carried in the proxy metadata; if the parent directory identifier of the file is not the identifier of the second directory, the metadata of the found file will be The file is set to be hidden; if the parent directory identifier of the file is the identifier of the second directory, the file is not processed.
在具体实施时, 终端可能先发起对第一目录的同步, 也有可能先发起 对第二目录的同步。 当终端先同步第一目录时, 如果终端根据服务器返回 的代理元数据确定第一目录下有文件移动到了第二目录中, 此时, 终端可 以直接通过更改该文件的元数据中父目录将该文件移动到第二目录, 也可 以将第一目录下的该文件设置为隐藏, 而不删除该文件。 其中, 将该文件 设置为隐藏, 是为了提高用户体验, 以免在终端还未同步第二目录时, 就 更改终端中的第二目录。 而且将文件设置为隐藏, 不仅可以使终端在同步 第二目录时还可以找到该文件, 而不用从服务器重新下载该文件。 而且, 在用户看来, 终端的第一目录与服务器的第一目录下的文件也能保持一 致。  In a specific implementation, the terminal may initiate synchronization of the first directory first, and may also initiate synchronization of the second directory. When the terminal first synchronizes the first directory, if the terminal determines that the file in the first directory is moved to the second directory according to the proxy metadata returned by the server, the terminal may directly change the parent directory in the metadata of the file. The file is moved to the second directory, and the file in the first directory can also be set to be hidden without deleting the file. The file is set to be hidden to improve the user experience, so that the second directory in the terminal is changed when the terminal has not synchronized the second directory. Moreover, setting the file to be hidden can not only enable the terminal to find the file when it synchronizes the second directory, but does not have to re-download the file from the server. Moreover, in the user's view, the first directory of the terminal and the file in the first directory of the server are also consistent.
如果终端先同步第二目录, 则在终端同步第一目录时, 就会出现文件 的父目录标识已更改为第二目录的标识的情况。 因此, 当终端判断出第一 文件的父目录标识为第二目录的标识, 则不对该文件做处理。  If the terminal synchronizes the second directory first, when the terminal synchronizes the first directory, the case where the parent directory identifier of the file has been changed to the identifier of the second directory occurs. Therefore, when the terminal determines that the parent directory identifier of the first file is the identifier of the second directory, the file is not processed.
如果终端先同步第一目录, 则可能会存在该文件被设置成隐藏状态的 情况。 因此, 终端在接收到该文件的元数据时, 可以进一步判断该文件是 否被设置为了隐藏状态, 若设置为了隐藏状态, 则将该文件更改为显示状 态, 若未设置为隐藏状态, 则无需更改该文件的状态。  If the terminal synchronizes the first directory first, there may be cases where the file is set to the hidden state. Therefore, when receiving the metadata of the file, the terminal may further determine whether the file is set to be hidden. If it is set to hide the state, the file is changed to the display state. If it is not set to the hidden state, no change is needed. The status of the file.
本发明实施例中, 服务器通过更改文件的父目录的方式将文件从第一 目录移动到第二目录, 并在第一目录下为已移动到第二目录的文件创建代 理元数据, 使得终端在与服务器同步第一目录时, 服务器可以将表示文件 发生移动的代理元数据发送给终端, 终端可以通过该代理元数据识别出服 务器侧发生的是移动操作, 从而通过终端本地的文件来完成与服务器的同 步, 而无需从服务器侧重新下载文件, 节约了网络资源。 而且本发明通过 更改文件的父目录的方式将文件从源目录移动到目的目录, 使得文件的逻 辑号保持不变, 从而可以保持原有关联文件 f 的共享、 公开以及外链的链 接仍然有效。 服务器发同步请求为例进行说明, 假设终端 A和终端 B是用户与云端的服 务器保持同步的两个终端, 被移动的文件为 f , 文件 f 的源目录为 S , 目 标目录为 0。 如图 4所示, 图 4为本实施例提供的同步方法的流程图, 该 方法具体包括: In the embodiment of the present invention, the server changes the file from the first directory by changing the parent directory of the file. The directory is moved to the second directory, and the proxy metadata is created in the first directory for the file that has been moved to the second directory, so that when the terminal synchronizes the first directory with the server, the server can send the proxy metadata indicating that the file is moved. To the terminal, the terminal can identify, by the proxy metadata, that a mobile operation occurs on the server side, thereby completing synchronization with the server through the local file of the terminal, without re-downloading the file from the server side, thereby saving network resources. Moreover, the present invention moves the file from the source directory to the destination directory by changing the parent directory of the file, so that the logical number of the file remains unchanged, so that the shared, public, and external links of the original associated file f can remain valid. The server sends a synchronization request as an example. Assume that terminal A and terminal B are two terminals that keep the user synchronized with the cloud server. The file to be moved is f, the source directory of file f is S, and the target directory is 0. As shown in FIG. 4, FIG. 4 is a flowchart of a synchronization method according to the embodiment, where the method specifically includes:
S400 , 终端 A将本地源目录 S下的文件 f 移动到目标目录 D下。  S400, terminal A moves the file f in the local source directory S to the target directory D.
本实施例以用户与服务器同步的多个终端中的一个终端发生文件移 动为例进行说明。 如果是用户釆用 Web客户端操作云端的服务器进行文件 移动, 则可省略步骤 S400。  In this embodiment, a file shift occurs in one of a plurality of terminals synchronized by the user and the server as an example. If the user uses the web client to operate the cloud server for file movement, step S400 may be omitted.
文件 f 与目录之间的归属关系可通过文件 f 的元数据来描述, 文件 f 的元数据的数据结构如表 1所示:  The attribution relationship between the file f and the directory can be described by the metadata of the file f. The data structure of the metadata of the file f is as shown in Table 1:
表 1
Figure imgf000021_0001
其中, 文件标识可釆用系统生成的文件逻辑号来表示。 表 1所示的元 数据的数据结构仅为举例, 在具体应用时, 还可包括其它属性或仅包含表
Table 1
Figure imgf000021_0001
The file identifier can be represented by the logical number of the file generated by the system. The data structure of the metadata shown in Table 1 is only an example, and may include other attributes or only tables in specific applications.
1中的部分属性。 Part of the properties in 1.
S402 , 终端 A向云端的服务器发送将文件 f 从目录 S移动到目录 D的 请求。  S402. Terminal A sends a request to move the file f from the directory S to the directory D to the cloud server.
其中, 该请求中可以包括用户的账号, 文件 f 的标识, 目标目录 D的 标识, 操作类型。 本实施例中, 操作类型为移动操作。  The request may include an account of the user, an identifier of the file f, an identifier of the target directory D, and an operation type. In this embodiment, the operation type is a mobile operation.
S404 , 服务器在源目录 S下创建文件 f 的代理元数据 f, , 并在文件 f 的元数据中将文件 f 的父目录修改为目标目录 D。  S404, the server creates the proxy metadata f, in the source directory S, and modifies the parent directory of the file f to the target directory D in the metadata of the file f.
服务器根据接收到的请求中携带的用户的账号获取用户存储在云端 的数据。 在用户的数据中查找文件 f 的元数据, 并在文件 f 的元数据中将 文件 f 的父目录修改为目标目录 D。 如图 5所示, 图 5为文件 f 的移动示 意图。 移动前目录 A下面有源目录 S和目标目录 D , 源目录 S下面有文件 f。 移动后源目录 S下存放文件 f 的代理元数据 Γ , 文件 f 位于目录 D 下。  The server obtains the data stored by the user in the cloud according to the account of the user carried in the received request. Find the metadata of file f in the user's data, and modify the parent directory of file f to the target directory D in the metadata of file f. As shown in Fig. 5, Fig. 5 is a schematic diagram of the movement of the file f. Before moving the directory A below the active directory S and the target directory D, the source directory S has a file f below. After the move, the source directory of the file f is stored under the source directory S, and the file f is located under the directory D.
其中, 移动后的文件 f 的元数据的数据结构如表 2所示:  The data structure of the metadata of the moved file f is as shown in Table 2:
表 2
Figure imgf000022_0001
Table 2
Figure imgf000022_0001
文件 f 的代理元数据 Γ 的数据结构如表 3所示: 表 3
Figure imgf000023_0001
在移动文件的过程中, 有可能在目录 D中已经存在有文件 f 的代理元 数据 f, 。 因此, 服务器还可以先检查目标目录 D下面是否有该文件 f 的 代理元数据; 如果没有, 则直接执行步骤 S404 ; 如果目标目录 D下面有该 文件 f 的代理元数据, 则服务器还进一步删除目标目录 D下的该文件 f 的 代理元数据, 并执行步骤 S404。
The data structure of the proxy metadata 文件 of file f is shown in Table 3: table 3
Figure imgf000023_0001
In the process of moving the file, it is possible that the proxy metadata f of the file f already exists in the directory D. Therefore, the server may also first check whether there is proxy metadata of the file f under the target directory D; if not, directly execute step S404; if there is proxy metadata of the file f under the target directory D, the server further deletes the target. The proxy metadata of the file f under the directory D, and step S404 is performed.
S406 , 服务器向该用户与服务器同步的终端 B推送更新通知。  S406. The server pushes an update notification to the terminal B that the user synchronizes with the server.
终端可以主动向服务器发起同步第一目录的请求, 也可以根据服务器 发送的关于第一目录的更新通知来发起同步请求。 本实施例以服务器向终 端发送更新通知为例进行说明。  The terminal may initiate a request to synchronize the first directory to the server, or may initiate a synchronization request according to an update notification sent by the server about the first directory. This embodiment is described by taking an example in which the server sends an update notification to the terminal.
当用户有多个终端与服务器保持同步时, 服务器可以维护用户的各个 在线终端的连接。 当服务器检测到用户的数据发生更新后, 可以分别向用 户已连接到服务器的各同步终端发送更新通知。 在发起更新通知时, 可以 不再向发起移动请求中终端 A发送。  When the user has multiple terminals synchronized with the server, the server can maintain the connection of the user's various online terminals. After the server detects that the user's data has been updated, it can send an update notification to each synchronization terminal that the user has connected to the server. When the update notification is initiated, it may no longer be sent to the terminal A initiating the mobile request.
服务器可以分别发送源目录 S和目标目录 D的更新通知, 也可以以一 条更新通知来通知源目录 S和目标目录 D的更新。  The server may separately send an update notification of the source directory S and the target directory D, or may notify the update of the source directory S and the target directory D with an update notification.
S408 , 终端 B向服务器发起同步目录 S的同步请求。  S408. The terminal B initiates a synchronization request for synchronizing the directory S to the server.
其中, 同步请求中携带目录 S的标识和同步令牌环 syncToken , 该同 步令牌环 syncToken用来表示每次的同步的序列号。  The synchronization request carries the identifier of the directory S and the synchronization token ring syncToken, and the synchronization token ring syncToken is used to indicate the serial number of each synchronization.
S41 0 , 服务器检测目录 S下的更新数据, 检测到更新数据为文件 f 的 代理元数据时, 将该代理元数据返回给终端。 S41 0, the server detects the update data in the directory S, and detects the update data as the file f. When proxy metadata, the proxy metadata is returned to the terminal.
服务器接收到终端 B发起的同步目录 S的请求后, 会返回目录 S下新 增或修改的文件的元数据。 具体的, 服务器根据终端 B请求的 syncToken 检测出源目录 S下自从上次的 s yncToken后的所有的更新数据, 同时产生 一个新的 syncToken做下次该终端端同步的 syncToken, 最后服务器返回 更新数据和新的 s yncToken。  After receiving the request of the synchronization directory S initiated by the terminal B, the server returns the metadata of the newly added or modified file in the directory S. Specifically, the server detects all the update data from the source directory S since the last syncToken according to the syncToken requested by the terminal B, and simultaneously generates a new syncToken to perform the synchronizationTo the next time the terminal synchronizes, and finally the server returns the update data. And the new s yncToken.
假设用户发起同步目录 S和目录 D时, 携带的 syncToken为  Assume that when the user initiates synchronization of directory S and directory D, the syncToken carried is
20121128000000, 服务器检测出自从 20121128000000后源目录 S的更新 数据为文件的代理元数据 Γ , 返回源目录 S下的更新数据, 并且设置新 的 syncToken为 20121128120000.  20121128000000, the server detects the update data of the source directory S since 20121128000000 as the proxy metadata of the file Γ , returns the update data under the source directory S, and sets the new syncToken to 20121128120000.
S412, 终端 B根据服务器返回的代理元数据 Γ 将本地的文件 f 设置 为隐藏。  S412, terminal B sets the local file f to be hidden according to the proxy metadata returned by the server.
终端 B接收到服务器返回的更新数据后, 根据数据中的移动标记确定 文件 f 已从目录 S中移走。 终端 B在本地查找到文件 f 的元数据, 在文件 f 的元数据中将文件 f 设置为隐藏。 具体的, 被设置为隐藏的文件 f 的元 数据的数据结构如表 4所示:  After receiving the update data returned by the server, terminal B determines that the file f has been removed from the directory S based on the movement flag in the data. Terminal B finds the metadata of file f locally, and sets file f to be hidden in the metadata of file f. Specifically, the data structure of the metadata of the file f set to be hidden is as shown in Table 4:
表 4
Figure imgf000024_0001
Table 4
Figure imgf000024_0001
文件 f 被设置成隐藏后, 在目录 S下将不会出现文件 f, 使得目录 S 保持了与云端的同步。 同时, 又避免了删除文件 f, 使得后续在同步目录 After the file f is set to be hidden, the file f will not appear under the directory S, so that the directory S remains synchronized with the cloud. At the same time, it avoids deleting the file f, so that the subsequent directory is synchronized.
D时, 可以直接将文件 f 移动到目录 D中。 当然, 终端 B也可以不将文件 f 设置为隐藏, 而直接将文件 f 的父目 录更改为目录 D , 这样, 同样能使文件 f 从目录 S中移走。 但是, 当用户 仅选择性同步目录 S , 而不同步目录 D时, 这种方式会导致目录 D也发生 变化, 影响用户体验。 When D, the file f can be directly moved to the directory D. Of course, the terminal B can also change the parent directory of the file f to the directory D without setting the file f to be hidden, so that the file f can also be removed from the directory S. However, when the user only selectively synchronizes the directory S without synchronizing the directory D, this method causes the directory D to also change, affecting the user experience.
本实施例以将文件 f 设置成隐藏为例进行说明。  This embodiment is described by taking the file f as hidden as an example.
S414 , 终端 B向服务器发起同步目录 D的同步请求。  S414. The terminal B initiates a synchronization request for synchronizing the directory D to the server.
其中, 同步请求中携带目录 D的标识和同步令牌环 syncToken。  The synchronization request carries the identifier of the directory D and the synchronization token ring syncToken.
S41 6 , 服务器检测目录 D下的更新数据, 检测到更新数据为文件 f 的 元数据时, 将该文件 f 的元数据返回给终端。  S41 6: The server detects the update data in the directory D, and when detecting the update data as the metadata of the file f, returns the metadata of the file f to the terminal.
服务器检测更新数据的过程可参考步骤 S41 0中的说明, 这里不再赘 述。  For the process of detecting the update data by the server, refer to the description in step S41 0, which is not described here.
S41 8 , 终端 B根据服务器返回文件 f 的元数据将本地的文件 f 的父目 录更改为目录 D。  S41 8 , terminal B changes the parent directory of the local file f to the directory D according to the metadata of the server returning the file f.
终端 B接收到文件 f 的元数据后,发现文件 f 的父目录更改为目录 D , 则查找本地的文件 f 的元数据, 在查找到的元数据中将 f 的父目录更改为 目录 D。 另外, 终端 B还进一步判断文件 f 的状态, 如果文件 f 已被设置 为隐藏状态, 则终端 B还进一步将文件 f 的状态更改为显示状态。  After receiving the metadata of the file f, the terminal B finds that the parent directory of the file f is changed to the directory D, and then searches for the metadata of the local file f, and changes the parent directory of f to the directory D in the found metadata. In addition, the terminal B further judges the state of the file f. If the file f has been set to the hidden state, the terminal B further changes the state of the file f to the display state.
需要说明的是, 上述步骤 S408-S41 2与步骤 S414-S41 8之间没有先后 顺序, 终端 B可以先同步目录 S , 也可以先同步目录 D。  It should be noted that there is no sequence between the above steps S408-S41 2 and steps S414-S41 8 , and terminal B may synchronize the directory S first, or may synchronize the directory D first.
上述方法实施例可以应用在云端服务器和终端的同步中, 其中实现同 步的网络架构如图 6所示, 可以包括: 客户端, 同步服务器和推送服务器。  The foregoing method embodiment can be applied to the synchronization between the cloud server and the terminal. The network architecture for implementing the synchronization is as shown in FIG. 6, and may include: a client, a synchronization server, and a push server.
其中, 同步服务器和推送服务器均位于云端, 两者可以合设在一个物 理设备中。 本发明实施例所称的服务器是云端的同步服务器和推送服务器 的合称, 不过, 本发明实施例中推送服务器可以是可选的, 在不需要推送 服务器的实施例中本发明实施例中所称的服务器则指同步服务器。 Wherein, the synchronization server and the push server are both located in the cloud, and the two can be combined in one object. In the device. The server in the embodiment of the present invention is a combination of the synchronization server and the push server in the cloud. However, in the embodiment of the present invention, the push server may be optional. In the embodiment that does not require the push server, the embodiment of the present invention is The so-called server refers to the synchronization server.
客户端运行在用户终端上, 实现终端与同步服务器之间的同步。 客户 端和同步服务器可以通过 HTTP协议通信。 另外, 客户端可以通过注册连 接到推送服务器, 以接收推送服务器推送的消息。 客户端和推送服务器可 以通过 HTTP或者 XMPP协议来建立连接。  The client runs on the user terminal to synchronize between the terminal and the synchronization server. The client and the sync server can communicate via the HTTP protocol. In addition, the client can connect to the push server through registration to receive messages pushed by the push server. The client and push server can establish a connection via HTTP or XMPP.
上述网络架构中各设备之间的交互过程如下: 终端中的客户端首先建 立与推送服务器之间的连接。 当同步服务器检测出有数据更新时, 同步服 务器向推送服务器发送更新通知。 推送服务器将该更新通知推送到终端中 的客户端。 客户端根据该更新通知发起与同步服务器的同步。  The interaction process between devices in the above network architecture is as follows: The client in the terminal first establishes a connection with the push server. When the synchronization server detects a data update, the synchronization server sends an update notification to the push server. The push server pushes the update notification to the client in the terminal. The client initiates synchronization with the synchronization server based on the update notification.
下面对上述网络结构中的各设备的结构进行详细介绍。 如图 7所示, 图 7为本发明实施例提供的与终端进行同步的服务器 700的结构示意图, 该服务器 700为实现云端的功能的装置。 该服务器 700可以包括:  The structure of each device in the above network structure will be described in detail below. As shown in FIG. 7, FIG. 7 is a schematic structural diagram of a server 700 that synchronizes with a terminal according to an embodiment of the present invention. The server 700 is a device that implements a function of a cloud. The server 700 can include:
接收单元 701 , 用于接收将文件从第一目录移动到第二目录的请求, 以及请求中携带该文件的标识和第二目录的标识;  The receiving unit 701 is configured to receive a request to move the file from the first directory to the second directory, and the identifier of the file and the identifier of the second directory in the request;
处理单元 702 , 用于根据接收单元 701接收到的该文件的标识查找该 文件的元数据, 在该文件的元数据中将该文件的父目录标识更改为第二目 录的标识, 并在第一目录下创建该文件的代理元数据, 该代理元数据用于 表示该文件已移动到所述第二目录;  The processing unit 702 is configured to search for metadata of the file according to the identifier of the file received by the receiving unit 701, and change the parent directory identifier of the file to the identifier of the second directory in the metadata of the file, and at the first The proxy metadata of the file is created under the directory, and the proxy metadata is used to indicate that the file has been moved to the second directory;
同步单元 703 , 用于将该文件的代理元数据发送给终端, 以通过终端 本地的该文件来进行服务器和终端之间的同步。 其中, 接收单元 701接收到的请求中携带有需要移动的文件的标识以 及该文件的目标目录的标识。 而本实施例中, 要移动的文件的源目录为第 一目录, 目标目录为第二目录, 因此服务器接收到的请求中需要携带第二 目录的标识。 对于文件的源目录的标识则可以携带, 也可以不携带。 The synchronization unit 703 is configured to send the proxy metadata of the file to the terminal to perform synchronization between the server and the terminal through the file local to the terminal. The request received by the receiving unit 701 carries the identifier of the file that needs to be moved and the identifier of the target directory of the file. In this embodiment, the source directory of the file to be moved is the first directory, and the target directory is the second directory, so the request received by the server needs to carry the identifier of the second directory. The identifier of the source directory of the file may or may not be carried.
处理单元 702在接收单元 701接收到移动文件的请求后, 可以根据请 求的名称或者请求中指定的操作类型来确定接收到的请求为执行移动操 作的请求。 其中, 处理单元 702在将文件的父目录标识更改为第二目录的 标识时, 还进一步用于判断第二目录下是否存在用于指示该文件已从第二 目录移除的代理元数据; 若第二目录下存在用于指示该文件已从第二目录 移除的代理元数据, 则删除第二目录下的代理元数据。  After receiving the request to move the file, the processing unit 702 may determine the received request as a request to perform the move operation according to the name of the request or the type of operation specified in the request. When the processing unit 702 changes the parent directory identifier of the file to the identifier of the second directory, it is further used to determine whether there is proxy metadata for indicating that the file has been removed from the second directory in the second directory; The proxy metadata for indicating that the file has been removed from the second directory exists under the second directory, and the proxy metadata under the second directory is deleted.
同步单元 703检测要同步的目录中自上次同步后的更新数据, 将检测 到的更新数据发送给终端。 比如, 本实施例, 当要与终端同步第一目录时, 同步单元 703检测第一目录在本次同步与上次同步期间的更新数据, 在确 定该更新数据包括代理元数据时, 则将第一目录下的代理元数据发送给终 端。 当要同步第二目录时, 同步单元 703检测第二目录在本次同步与上次 同步期间的更新数据, 在确定该更新数据包括有被移动到第二目录的文件 的元数据时, 将该文件的元数据发送给终端。  The synchronization unit 703 detects the update data since the last synchronization in the directory to be synchronized, and transmits the detected update data to the terminal. For example, in this embodiment, when the first directory is to be synchronized with the terminal, the synchronization unit 703 detects the update data of the first directory during the current synchronization and the last synchronization, and when determining that the update data includes the proxy metadata, The proxy metadata in a directory is sent to the terminal. When the second directory is to be synchronized, the synchronization unit 703 detects the update data of the second directory during the current synchronization and the last synchronization, and when determining that the update data includes the metadata of the file moved to the second directory, The metadata of the file is sent to the terminal.
在本发明实施例中, 通过更改文件的父目录的方式将文件从源目录移 动到目的目录, 并在源目录下为已移动到目标目录的文件创建代理元数 据, 使得终端在同步源目录和目标目录时, 可以识别出服务器侧发生的是 移动操作, 从而在终端本地按移动操作执行, 而无需从服务器侧重新下载 文件, 节约了网络资源。 而且本发明通过更改文件的父目录的方式将文件 从源目录移动到目的目录, 使得文件的逻辑号保持不变, 从而可以保持原 有关联文件 f 的共享、 公开以及外链的链接仍然有效。 In the embodiment of the present invention, the file is moved from the source directory to the destination directory by changing the parent directory of the file, and the proxy metadata is created in the source directory for the file that has been moved to the target directory, so that the terminal is in the synchronization source directory and When the target directory is located, it can be recognized that the mobile operation occurs on the server side, so that the mobile terminal performs the local operation according to the mobile operation without saving the file from the server side, thereby saving network resources. Moreover, the present invention converts the file by changing the parent directory of the file. Moving from the source directory to the destination directory keeps the logical number of the file unchanged, so that the shared, public, and external links of the original associated file f remain valid.
另外, 为了节约存储资源, 在本发明的另一实施例中, 还可以定期清 除代理元数据。 如图 8所示, 图 8为本发明另一实施例提供的与终端进行 同步的服务器 700的结构示意图, 该服务器 700在图 7所示实施例的基础 上还可以进一步包括: 维护单元 704 , 用于根据预设时限, 删除服务器中 超期的代理元数据。  In addition, in order to save storage resources, in another embodiment of the present invention, proxy metadata may also be periodically cleared. As shown in FIG. 8, FIG. 8 is a schematic structural diagram of a server 700 for synchronizing with a terminal according to another embodiment of the present invention. The server 700 further includes: a maintenance unit 704, based on the embodiment shown in FIG. Used to delete the expired agent metadata in the server according to the preset time limit.
另外, 该服务器还可以在图 7所示实施例的基础上进一步包括: 通知 单元 705 , 用于向与该服务器同步的终端发送第一目录和第二目录的更新 通知, 以便该终端根据所述更新通知发起同步所述第一目录或第二目录的 请求。  In addition, the server may further include: a notification unit 705, configured to send, to the terminal synchronized with the server, an update notification of the first directory and the second directory, so that the terminal is configured according to the The update notification initiates a request to synchronize the first directory or the second directory.
图 7和图 8所示实施例中的各单元的功能的具体实现可参考方法实施 例部分, 这里不再赘述。  The specific implementation of the functions of the units in the embodiment shown in FIG. 7 and FIG. 8 can be referred to the method embodiment, and details are not described herein again.
本发明另一实施例提供的与服务器进行同步的终端 900如图 9所示。 该终端 900可以包括:  A terminal 900 synchronized with a server according to another embodiment of the present invention is shown in FIG. The terminal 900 can include:
同步单元 901 , 用于在服务器通过在文件的元数据中更改该文件的父 目录标识的方式将该文件从第一目录移动到第二目录, 并在第一目录下创 建该文件的代理元数据后, 从服务器接收该文件的代理元数据, 并提供给 处理单元 902 , 其中, 该代理元数据用于表示该文件已移动到第二目录; 处理单元 902 , 用于根据该代理元数据在终端本地查找该文件的元数 据, 通过在本地查找到的该文件的元数据来完成与所述服务器的同步。  The synchronization unit 901 is configured to move the file from the first directory to the second directory by changing the parent directory identifier of the file in the metadata of the file, and create proxy metadata of the file in the first directory. After receiving the proxy metadata of the file from the server, and providing it to the processing unit 902, where the proxy metadata is used to indicate that the file has been moved to the second directory; the processing unit 902 is configured to use the proxy metadata according to the proxy metadata The metadata of the file is locally looked up, and the synchronization with the server is completed by the metadata of the file found locally.
其中, 代理元数据可以包括文件的标识, 第二目录的标识以及移动标 记。 其中, 移动标记用于指示该文件已发生移动, 终端在接收到更新数据 移动时的目标目录, 即该文件当前的父目录。 Wherein, the proxy metadata may include an identifier of the file, an identifier of the second directory, and a moving target Remember. The mobile tag is used to indicate that the file has moved, and the target directory when the terminal receives the update data movement, that is, the current parent directory of the file.
处理单元 902具体可用于根据代理元数据中的移动标记确定该文件已 发生移动; 根据该文件的标识在本地查找所述文件的元数据; 在查找到的 该文件的元数据中将该文件的父目录标识更改为第二目录的标识。  The processing unit 902 is specifically configured to determine, according to the mobile tag in the proxy metadata, that the file has moved; searching for metadata of the file locally according to the identifier of the file; and searching for the file in the metadata of the file The parent directory ID is changed to the ID of the second directory.
在本发明另一实施例中, 同步单元 901还可用于从所述服务器接收所 述文件的元数据。 本实施例中, 处理单元 902的具体结构可以如图 10所 示, 该处理单元 902具体可以包括:  In another embodiment of the present invention, the synchronization unit 901 is further operable to receive metadata of the file from the server. In this embodiment, the specific structure of the processing unit 902 may be as shown in FIG. 10, and the processing unit 902 may specifically include:
第一操作模块 9021 ,用于根据代理元数据在终端本地查找该文件的元 数据, 通过在本地查找到的该文件的元数据来完成本地的第一目录与服务 器中的第一目录的同步;  The first operation module 9021 is configured to search for metadata of the file locally in the terminal according to the proxy metadata, and complete synchronization of the first directory in the local directory with the first directory in the server by using the metadata of the file locally found;
第二操作模块 9022 ,用于根据接收到的文件的元数据完成本地的第二 目录与服务器中的第二目录的同步。  The second operation module 9022 is configured to complete synchronization of the local second directory with the second directory in the server according to the metadata of the received file.
其中, 同步单元 901从服务器接收的文件的元数据可包括文件的标识 和第二目录的标识。 第二操作模块 9022 , 具体可用于根据接收到的文件的 元数据中的该文件的标识在本地查找该文件的元数据; 在查找到的该文件 的元数据中将该文件的父目录标识更改为第二目录的标识。  The metadata of the file received by the synchronization unit 901 from the server may include an identifier of the file and an identifier of the second directory. The second operation module 9022 is specifically configured to locally search for metadata of the file according to the identifier of the file in the metadata of the received file; change the parent directory identifier of the file in the found metadata of the file. The identifier for the second directory.
第一操作模块 9021具体可用于根据代理元数据中的移动标记确定该 文件已发生移动; 根据该代理元数据中的文件的标识在本地查找该文件的 元数据; 判断查找到的该文件的元数据中该文件的父目录标识是否为第二 目录的标识; 若该文件的父目录标识不是第二目录的标识, 则在查找到的 该文件的元数据中将该文件设置为隐藏; 若该文件的父目录标识是所述第 二目录的标识, 则不对所述文件做处理。 The first operation module 9021 is specifically configured to determine, according to the mobile tag in the proxy metadata, that the file has moved; to find the metadata of the file locally according to the identifier of the file in the proxy metadata; and determine the found element of the file. Whether the parent directory identifier of the file in the data is the identifier of the second directory; if the parent directory identifier of the file is not the identifier of the second directory, the found The file is set to be hidden in the metadata of the file; if the parent directory identifier of the file is the identifier of the second directory, the file is not processed.
另外, 第二操作模块 9022还用于在查找到该文件的元数据后, 确定 第二文件的状态, 若第二文件处于隐藏状态, 则在第二文件的元数据中将 第二文件更改为显示状态。  In addition, the second operation module 9022 is further configured to determine a state of the second file after the metadata of the file is found, and if the second file is in a hidden state, change the second file to the metadata of the second file to Display state.
图 10所示的终端 900可以主动向服务器发起同步第一目录的请求, 也可以根据服务器发送的关于第一目录的更新通知来发起同步请求。 在接 收更新通知的实施例中, 图 10所示的终端 900中的同步单元 901还用于 与服务器建立连接, 在服务器将文件从第一目录移动到第二目录后, 接收 服务器发送的关于第一目录和第二目录的更新通知。  The terminal 900 shown in FIG. 10 may initiate a request for synchronizing the first directory to the server, or may initiate a synchronization request according to the update notification sent by the server regarding the first directory. In the embodiment of receiving the update notification, the synchronization unit 901 in the terminal 900 shown in FIG. 10 is further configured to establish a connection with the server, and after the server moves the file from the first directory to the second directory, the receiving server sends the Update notification for a directory and a second directory.
图 9和图 10所示实施例中的各单元的功能的具体实现可参考方法实 施例部分, 这里不再赘述。  The specific implementation of the functions of the units in the embodiment shown in FIG. 9 and FIG. 10 can be referred to the method embodiment, and details are not described herein again.
需要说明的是, 本发明图 7和图 8所示实施例中的服务器 700可基于 计算机的硬件结构来实现, 如图 11所述, 该装置 700的硬件结构包括存 储器 1101、 收发器 1102, 处理器 1103和总线 1104。  It should be noted that the server 700 in the embodiment shown in FIG. 7 and FIG. 8 can be implemented based on the hardware structure of the computer. As shown in FIG. 11, the hardware structure of the device 700 includes a memory 1101, a transceiver 1102, and processing. The device 1103 and the bus 1104.
其中, 处理器 1103、 存储器 1101和收发器 1102通过总线 1104通信 连接。  The processor 1103, the memory 1101, and the transceiver 1102 are communicably connected by a bus 1104.
存储器 1101可以是只读存储器 (Read Only Memory, ROM) , 静态存 储设备,动态存储设备或者随机存取存储器( Random Access Memory, RAM )。 存储器 1101可以存储操作系统和其他应用程序的指令以及应用数据。 存 储器 1101中存储的指令由处理器 1103来运行执行。  The memory 1101 may be a read only memory (ROM), a static storage device, a dynamic storage device, or a random access memory (RAM). The memory 1101 can store instructions of the operating system and other applications as well as application data. The instructions stored in the memory 1101 are executed by the processor 1103.
本发明实施例中存储器 1101可用于存储实现图 7以及图 8所示实施 例中各功能单元的指令。 The memory 1101 in the embodiment of the present invention can be used to store and implement the implementation shown in FIG. 7 and FIG. 8. The instructions for each functional unit in the example.
收发器 1102用来实现装置 700与其他设备之间的通信。  Transceiver 1102 is used to enable communication between device 700 and other devices.
本发明实施例中, 收发器 1102用于接收来自终端的消息以及向终端 发送消息。  In the embodiment of the present invention, the transceiver 1102 is configured to receive a message from a terminal and send a message to the terminal.
处理器 1103可以釆用通用的中央处理器( Central Processing Unit, CPU) , 处理器, 应用专用集成电路(Application Specific Integrated Circuit, ASIC) , 或者一个或多个集成电路, 用于执行相关程序。  The processor 1103 can use a general-purpose central processing unit (CPU), a processor, an application specific integrated circuit (ASIC), or one or more integrated circuits for executing related programs.
本发明实施例中, 处理器 1103用于执行存储器 1101中的指令, 具体 可执行图 2所示方法实施例中的步骤, 这里不再赘述。  In the embodiment of the present invention, the processor 1103 is configured to execute the instructions in the memory 1101, and the steps in the method embodiment shown in FIG. 2 are specifically executed, and details are not described herein again.
总线 1104可包括一通路, 在同步装置 700各个部件 (例如处理器 1103、 存储器 1101和接收器 1102 ) 之间传送信息。  Bus 1104 can include a path for communicating information between various components of synchronization device 700, such as processor 1103, memory 1101, and receiver 1102.
上述图 9和图 10所示实施例中的终端 900同样可基于计算机的硬件 结构来实现, 如图 12所述, 该终端 900的硬件结构包括存储器 1201、 收 发器 1202, 处理器 1203和总线 1204。  The terminal 900 in the foregoing embodiment shown in FIG. 9 and FIG. 10 can also be implemented based on the hardware structure of the computer. As shown in FIG. 12, the hardware structure of the terminal 900 includes a memory 1201, a transceiver 1202, a processor 1203, and a bus 1204. .
其中, 处理器 1203、 存储器 1201和收发器 1202通过总线 1204通信 连接。  The processor 1203, the memory 1201, and the transceiver 1202 are communicatively coupled by a bus 1204.
存储器 1201可以是只读存储器 (Read Only Memory, ROM) , 静态存 储设备,动态存储设备或者随机存取存储器( Random Access Memory, RAM )。 存储器 1201可以存储操作系统和其他应用程序的指令以及应用数据。 存 储器 1201中存储的指令由处理器 1203来运行执行。  The memory 1201 may be a read only memory (ROM), a static storage device, a dynamic storage device, or a random access memory (RAM). The memory 1201 can store instructions of the operating system and other applications as well as application data. The instructions stored in the memory 1201 are executed by the processor 1203.
本发明实施例中存储器 1201可用于存储实现图 9以及图 10所示实施 例中各功能单元的指令。 收发器 1202用来实现终端 900与其他设备或通信网络 (例如但不限 于以太网, 无线接入网 ( Radio Access Network, RAN ) , 无线局域网 ( Wireless Local Area Network, WLAN ) 等) 之间的通信。 本发明实施例中, 收发器 1202用于接收来自云端的服务器的消息以 及向云端的服务器发送消息。 The memory 1201 in the embodiment of the present invention can be used to store instructions for implementing the functional units in the embodiments shown in FIG. 9 and FIG. The transceiver 1202 is configured to implement communication between the terminal 900 and other devices or communication networks (such as, but not limited to, Ethernet, Radio Access Network (RAN), Wireless Local Area Network (WLAN), etc. . In the embodiment of the present invention, the transceiver 1202 is configured to receive a message from a server in the cloud and send a message to a server in the cloud.
处理器 1203可以釆用通用的中央处理器( Central Processing Unit, CPU) , 处理器, 应用专用集成电路(Application Specific Integrated Circuit, ASIC) , 或者一个或多个集成电路, 用于执行相关程序。  The processor 1203 can use a general-purpose central processing unit (CPU), a processor, an application specific integrated circuit (ASIC), or one or more integrated circuits for executing related programs.
本发明实施例中, 处理器 1203用于执行存储器 1201中的指令, 具体 可执行图 3所示方法实施例中的步骤, 这里不再赘述。  In the embodiment of the present invention, the processor 1203 is configured to execute the instructions in the memory 1201, and the steps in the method embodiment shown in FIG. 3 may be specifically executed, and details are not described herein again.
总线 1204可包括一通路, 在终端 900各个部件(例如处理器 1203、 存储器 1201和收发器 1202 ) 之间传送信息。 通过以上的实施例的描述, 本领域普通技术人员可以理解: 实现上述 实施例方法中的全部或部分步骤是可以通过程序来指令相关的硬件来完 成,所述的程序可以存储于一计算机可读取存储介质中,该程序在执行时, 包括如上述方法实施例的步骤, 所述的存储介质, 如: R0M/RAM、 磁碟、 光盘等。  Bus 1204 can include a path for communicating information between various components of terminal 900, such as processor 1203, memory 1201, and transceiver 1202. Through the description of the above embodiments, those skilled in the art can understand that all or part of the steps of the foregoing embodiment can be implemented by a program to instruct related hardware, and the program can be stored in a computer readable manner. In the storage medium, when the program is executed, the method includes the steps of the foregoing method embodiment, such as: ROM/RAM, magnetic disk, optical disk, and the like.
以上所述, 仅为本发明的具体实施例, 但本发明的保护范围并不局限 于此, 任何熟悉本技术领域的技术人员在本发明揭露的技术范围内, 可轻 易想到变化或替换, 都应涵盖在本发明的保护范围之内。 因此, 本发明的 保护范围应以权利要求的保护范围为准。  The above is only a specific embodiment of the present invention, but the scope of the present invention is not limited thereto, and any person skilled in the art can easily think of changes or substitutions within the technical scope of the present invention. It should be covered by the scope of the present invention. Therefore, the scope of the invention should be determined by the scope of the claims.

Claims

权 利 要 求 Rights request
1、 一种终端与服务器进行同步的方法, 其特征在于, 所述方法包括: 服务器接收将文件从第一目录移动到第二目录的请求, 所述请求中携 带所述文件的标识和所述第二目录的标识; 1. A method for synchronizing a terminal and a server, characterized in that the method includes: the server receives a request to move a file from a first directory to a second directory, and the request carries the identifier of the file and the The identification of the second directory;
服务器根据所述文件的标识查找所述文件的元数据, 在所述文件的元 数据中将所述文件的父目录标识更改为所述第二目录的标识, 并在所述第 一目录下创建所述文件的代理元数据, 所述代理元数据用于表示所述文件 已移动到第二目录; The server searches for the metadata of the file according to the identifier of the file, changes the parent directory identifier of the file in the metadata of the file to the identifier of the second directory, and creates it under the first directory. The proxy metadata of the file, the proxy metadata is used to indicate that the file has been moved to the second directory;
所述服务器将所述文件的代理元数据发送给所述终端, 以通过所述终 端本地的所述文件来进行所述服务器和所述终端之间的同步。 The server sends the proxy metadata of the file to the terminal to perform synchronization between the server and the terminal through the file local to the terminal.
2、 根据权利要求 1所述的方法, 其特征在于, 所述代理元数据包括所 述文件的标识, 第二目录的标识以及用于表示所述文件已发生移动的移动 标记; 2. The method according to claim 1, wherein the proxy metadata includes an identifier of the file, an identifier of the second directory, and a movement mark used to indicate that the file has been moved;
所述服务器将所述文件的代理元数据发送给终端后, 所述方法还包括: 所述终端根据所述代理元数据中的移动标记确定所述文件已发生移 动; After the server sends the proxy metadata of the file to the terminal, the method further includes: the terminal determines that the file has moved based on the movement mark in the proxy metadata;
根据所述文件的标识在本地查找所述文件的元数据; Search locally for the metadata of the file based on the identifier of the file;
在查找到的所述文件的元数据中将所述文件的父目录标识更改为所述 第二目录的标识。 In the found metadata of the file, the parent directory identifier of the file is changed to the identifier of the second directory.
3、 根据权利要求 1所述的方法, 其特征在于, 所述方法还包括: 将所 述文件的元数据发送给所述终端; 3. The method according to claim 1, wherein the method further includes: sending metadata of the file to the terminal;
所述终端根据所述文件的代理元数据更新所述终端中的第一目录, 并 根据所述文件的元数据更新所述终端中的第二目录。 The terminal updates the first directory in the terminal according to the proxy metadata of the file, and updates the second directory in the terminal according to the metadata of the file.
4、 根据权利要求 3所述的方法, 其特征在于, 所述文件的元数据包括 所述文件的标识和所述第二目录的标识; 4. The method according to claim 3, wherein the metadata of the file includes the identifier of the file and the identifier of the second directory;
所述根据所述文件的元数据更新所述终端中的第二目录具体包括: 所述终端根据所述文件的元数据中的所述文件的标识在本地查找所述 文件的元数据; The updating of the second directory in the terminal according to the metadata of the file specifically includes: the terminal locally searches for the file according to the identifier of the file in the metadata of the file. File metadata;
在查找到的所述文件的元数据中将所述文件的父目录标识更改为所述 第二目录的标识。 In the found metadata of the file, the parent directory identifier of the file is changed to the identifier of the second directory.
5、 根据权利要求 4所述的方法, 其特征在于, 所述代理元数据中包括 所述文件的标识, 第二目录的标识以及用于表示所述文件已发生移动的移 动标记; 5. The method according to claim 4, wherein the proxy metadata includes an identifier of the file, an identifier of the second directory, and a movement mark used to indicate that the file has been moved;
所述终端根据所述文件的代理元数据更新所述终端中的第一目录具体 包括: The terminal updating the first directory in the terminal according to the proxy metadata of the file specifically includes:
所述终端根据所述代理元数据中的移动标记确定所述文件已发生移 动; The terminal determines that the file has been moved based on the movement mark in the proxy metadata;
根据所述代理元数据中的文件的标识在本地查找所述文件的元数据; 判断查找到的所述文件的元数据中所述文件的父目录标识是否为所述 第二目录的标识; Search the metadata of the file locally according to the identifier of the file in the proxy metadata; Determine whether the parent directory identifier of the file in the found metadata of the file is the identifier of the second directory;
若所述文件的父目录标识不是所述第二目录的标识, 则在查找到的所 述文件的元数据中将所述文件设置为隐藏; If the parent directory identifier of the file is not the identifier of the second directory, then the file is set to be hidden in the metadata of the found file;
若所述文件的父目录标识是所述第二目录的标识, 则不对所述文件做 处理。 If the parent directory identifier of the file is the identifier of the second directory, the file will not be processed.
6、 根据权利要求 5所述的方法, 其特征在于, 在所述终端根据所述文 件的元数据中的所述文件的标识在本地查找到所述文件的元数据后, 所述 方法还包括: 确定所述文件的状态, 若所述文件为隐藏状态, 则在所述文 件的元数据中将所述文件更改为显示状态。 6. The method according to claim 5, wherein after the terminal locally finds the metadata of the file based on the identifier of the file in the metadata of the file, the method further includes: : Determine the status of the file. If the file is in the hidden status, change the file to the displayed status in the metadata of the file.
7、 根据权利要求 1-6任一项所述的方法, 其特征在于, 在所述服务器 根据所述文件的标识查找所述文件的元数据后, 所述方法还进一步包括: 服务器判断所述第二目录下是否存在表明所述文件已从所述第二目录 移走的代理元数据; 7. The method according to any one of claims 1 to 6, characterized in that, after the server searches for the metadata of the file according to the identifier of the file, the method further includes: the server determines that the Whether there is proxy metadata in the second directory indicating that the file has been moved from the second directory;
若所述第二目录下存在用于表明所述文件已从所述第二目录移走的代 理元数据, 则删除所述代理元数据。 If there is proxy metadata in the second directory that indicates that the file has been moved from the second directory, the proxy metadata is deleted.
8、 一种终端与服务器进行同步的方法, 其特征在于, 包括: 8. A method for synchronizing a terminal and a server, which is characterized by including:
在服务器通过在文件的元数据中更改所述文件的父目录标识的方式将 所述文件从第一目录移动到第二目录, 并在第一目录下创建所述文件的代 理元数据后, 终端从所述务器接收所述文件的代理元数据, 所述代理元数 据用于表示所述文件已移动到第二目录; After the server moves the file from the first directory to the second directory by changing the parent directory identification of the file in the file's metadata, and creates proxy metadata of the file under the first directory, the terminal Receive proxy metadata of the file from the server, where the proxy metadata is used to indicate that the file has been moved to the second directory;
所述终端根据所述代理元数据在终端本地查找所述文件的元数据, 通 过在本地查找到的所述文件的元数据来完成与所述服务器的同步。 The terminal searches for the metadata of the file locally based on the proxy metadata, and completes synchronization with the server through the metadata of the file found locally.
9、 根据权利要求 8所述的方法, 其特征在于, 所述代理元数据包括所 述文件的标识, 第二目录的标识以及用于表示所述文件已发生移动的移动 标记; 9. The method according to claim 8, wherein the proxy metadata includes an identifier of the file, an identifier of the second directory, and a movement mark used to indicate that the file has been moved;
所述终端根据所述代理元数据在终端本地查找所述文件的元数据, 通 过在本地查找到的所述文件的元数据来完成与所述服务器的同步具体包 括: The terminal searches the metadata of the file locally based on the proxy metadata, and completes the synchronization with the server through the metadata of the file found locally, which specifically includes:
所述终端根据所述代理元数据中的移动标记确定所述文件已发生移 动; The terminal determines that the file has been moved based on the movement mark in the proxy metadata;
根据所述文件的标识在本地查找所述文件的元数据; Search locally for the metadata of the file based on the identifier of the file;
在查找到的所述文件的元数据中将所述文件的父目录标识更改为所述 第二目录的标识。 In the found metadata of the file, the parent directory identifier of the file is changed to the identifier of the second directory.
10、 根据权利要求 8所述的方法, 其特征在于, 所述通过在本地查找 到的所述文件的元数据来完成与所述服务器的同步具体包括: 通过在本地 查找到的所述文件的元数据来完成所述终端中的第一目录与所述服务器 中的第一目录的同步; 10. The method according to claim 8, characterized in that: completing the synchronization with the server through the metadata of the file found locally specifically includes: using the metadata of the file found locally. metadata to complete the synchronization of the first directory in the terminal and the first directory in the server;
所述方法还包括: The method also includes:
所述终端从所述服务器接收所述文件的元数据; The terminal receives metadata of the file from the server;
所述终端根据接收到的所述文件的元数据完成所述终端中的第二目录 与所述服务器中的第二目录的同步。 The terminal completes synchronization of the second directory in the terminal and the second directory in the server according to the received metadata of the file.
11、 根据权利要求 10所述的方法, 其特征在于, 所述从所述服务器接 收的所述文件的元数据包括所述文件的标识和所述第二目录的标识; 所述终端根据所述文件的元数据完成所述终端中的第二目录与所述服 务器中的第二目录的同步具体包括: 11. The method according to claim 10, wherein the metadata of the file received from the server includes an identifier of the file and an identifier of the second directory; The metadata of the file completes the synchronization of the second directory in the terminal and the second directory in the server, which specifically includes:
所述终端根据接收到的所述文件的元数据中的所述文件的标识在本地 查找所述文件的元数据; The terminal locally searches for the metadata of the file based on the identification of the file in the received metadata of the file;
在查找到的所述文件的元数据中将所述文件的父目录标识更改为所述 第二目录的标识。 In the found metadata of the file, the parent directory identifier of the file is changed to the identifier of the second directory.
12、 根据权利要求 11所述的方法, 其特征在于, 所述代理元数据中包 括所述文件的标识, 第二目录的标识以及用于表示所述文件已发生移动的 移动标记; 12. The method according to claim 11, wherein the proxy metadata includes an identifier of the file, an identifier of the second directory, and a movement mark used to indicate that the file has been moved;
所述终端根据所述代理元数据在终端本地查找所述文件的元数据, 通 过在本地查找到的所述文件的元数据来完成所述终端中的第一目录与所 述服务器中的第一目录的同步具体包括: The terminal searches the metadata of the file locally according to the proxy metadata, and completes the first directory in the terminal and the first directory in the server through the metadata of the file found locally. Directory synchronization specifically includes:
所述终端根据所述代理元数据中的移动标记确定所述文件已发生移 动; The terminal determines that the file has been moved based on the movement mark in the proxy metadata;
根据所述代理元数据中的文件的标识在本地查找所述文件的元数据; 判断查找到的所述文件的元数据中所述文件的父目录标识是否为所述 第二目录的标识; Search the metadata of the file locally according to the identifier of the file in the proxy metadata; Determine whether the parent directory identifier of the file in the found metadata of the file is the identifier of the second directory;
若所述文件的父目录标识不是所述第二目录的标识, 则在查找到的所 述文件的元数据中将所述文件设置为隐藏; If the parent directory identifier of the file is not the identifier of the second directory, then the file is set to be hidden in the metadata of the found file;
若所述文件的父目录标识是所述第二目录的标识, 则不对所述文件做 处理。 If the parent directory identifier of the file is the identifier of the second directory, the file will not be processed.
13、 根据权利要求 12所述的方法, 其特征在于, 在所述终端根据所述 文件的元数据中的所述文件的标识在本地查找到所述文件的元数据后, 所 述方法还包括: 确定所述文件的状态, 若所述文件为隐藏状态, 则在所述 文件的元数据中将所述文件更改为显示状态。 13. The method according to claim 12, wherein after the terminal locally finds the metadata of the file based on the identifier of the file in the metadata of the file, the method further includes: : Determine the status of the file. If the file is in the hidden status, change the file to the displayed status in the metadata of the file.
14、 一种与终端进行同步的服务器, 其特征在于, 所述服务器包括: 接收单元, 用于接收将文件从第一目录移动到第二目录的请求, 所述 请求中携带所述文件的标识和所述第二目录的标识; 14. A server that synchronizes with a terminal, characterized in that the server includes: a receiving unit configured to receive a request to move a file from the first directory to the second directory, and the request carries the identifier of the file and the identification of the second directory;
处理单元, 用于根据所述文件的标识查找所述文件的元数据, 在所述 文件的元数据中将所述文件的父目录标识更改为所述第二目录的标识, 并 在所述第一目录下创建所述文件的代理元数据, 所述代理元数据用于表示 所述文件已移动到所述第二目录; A processing unit configured to search for the metadata of the file according to the identifier of the file, change the parent directory identifier of the file to the identifier of the second directory in the metadata of the file, and in the first Create proxy metadata for the file in a directory, where the proxy metadata is used to indicate that the file has been moved to the second directory;
同步单元, 用于将所述文件的代理元数据发送给终端, 以通过所述终 端本地的所述文件来进行所述服务器和所述终端之间的同步。 A synchronization unit, configured to send the proxy metadata of the file to the terminal, so as to perform synchronization between the server and the terminal through the file local to the terminal.
15、 如权利要求 14所述的服务器, 其特征在于, 所述同步单元还用于 将所述文件的元数据发送给所述终端; 所述文件的代理元数据用以同步第 一目录, 所述文件的元数据用以同步第二目录。 15. The server according to claim 14, wherein the synchronization unit is also used to send the metadata of the file to the terminal; the proxy metadata of the file is used to synchronize the first directory, so The metadata of the described file is used to synchronize the second directory.
16、 如权利要求 14或 15所述的服务器, 其特征在于, 所述处理单元 在将所述文件的父目录标识更改为所述第二目录的标识时, 还进一步用于 判断所述第二目录下是否存在用于表示所述文件已从所述第二目录移除 的代理元数据; 若所述第二目录下存在用于指示所述文件已从所述第二目 录移除的代理元数据, 则删除所述第二目录下的代理元数据。 16. The server according to claim 14 or 15, characterized in that, when changing the parent directory identifier of the file to the identifier of the second directory, the processing unit is further configured to determine the second directory identifier. Whether there is proxy metadata in the directory indicating that the file has been removed from the second directory; if there is proxy metadata in the second directory indicating that the file has been removed from the second directory. data, delete the proxy metadata in the second directory.
17、 一种与服务器进行同步的终端, 其特征在于, 包括: 17. A terminal that synchronizes with a server, characterized by including:
同步单元, 用于在服务器通过在文件的元数据中更改所述文件的父目 录标识的方式将所述文件从第一目录移动到第二目录, 并在第一目录下创 建所述文件的代理元数据后, 从所述服务器接收所述文件的代理元数据, 并提供给处理单元, 所述代理元数据用于表示所述文件已移动到第二目 录; A synchronization unit, configured to move the file from the first directory to the second directory by changing the parent directory identification of the file in the file's metadata on the server, and create a proxy for the file under the first directory. After receiving the metadata, receive the proxy metadata of the file from the server and provide it to the processing unit, where the proxy metadata is used to indicate that the file has been moved to the second directory;
所述处理单元, 用于根据所述代理元数据在终端本地查找所述文件的 元数据, 通过在本地查找到的所述文件的元数据来完成与所述服务器的同 步。 The processing unit is configured to search the metadata of the file locally on the terminal according to the proxy metadata, and complete synchronization with the server through the metadata of the file found locally.
18、 如权利要求 17所述的终端, 其特征在于, 所述代理元数据包括所 述第一文件的标识, 所述第二目录的标识以及用于指示所述文件已发生移 动的移动标记; 18. The terminal according to claim 17, wherein the proxy metadata includes an identifier of the first file, an identifier of the second directory, and a movement mark used to indicate that the file has been moved;
所述处理单元具体用于根据所述代理元数据中的移动标记确定所述文 件已发生移动; 根据所述文件的标识在本地查找所述文件的元数据; 在查 找到的所述文件的元数据中将所述文件的父目录标识更改为所述第二目 录的标识。 The processing unit is specifically configured to determine that the file has been moved according to the movement mark in the proxy metadata; to locally search for the metadata of the file according to the identification of the file; and to search for the metadata of the found file. In the data, the parent directory identifier of the file is changed to the identifier of the second directory.
19、 如权利要求 17所述的终端, 其特征在于, 所述同步单元还用于 从所述服务器接收所述文件的元数据; 19. The terminal according to claim 17, wherein the synchronization unit is further configured to receive metadata of the file from the server;
所述处理单元具体包括: The processing unit specifically includes:
第一操作模块, 用于根据所述代理元数据在终端本地查找所述文件的 元数据, 通过在本地查找到的所述文件的元数据来完成本地的第一目录与 所述服务器中的第一目录的同步; The first operation module is configured to search the metadata of the file locally in the terminal according to the proxy metadata, and complete the local first directory and the third directory in the server through the metadata of the file found locally. Synchronization of a directory;
第二操作模块, 用于根据接收到的所述文件的元数据完成本地的第二 目录与所述服务器中的第二目录的同步。 The second operation module is configured to complete the synchronization of the local second directory and the second directory in the server according to the received metadata of the file.
20、 如权利要求 19所述的终端, 其特征在于, 所述从所述服务器接 收的所述文件的元数据包括所述文件的标识和所述第二目录的标识; 所述第二操作模块具体用于根据接收到的所述文件的元数据中的所述 文件的标识在本地查找所述文件的元数据; 在查找到的所述文件的元数据 中将所述文件的父目录标识更改为所述第二目录的标识。 20. The terminal of claim 19, wherein the metadata of the file received from the server includes an identifier of the file and an identifier of the second directory; the second operation module Specifically configured to locally search for the metadata of the file according to the identifier of the file in the received metadata of the file; and change the parent directory identifier of the file in the found metadata of the file. is the identifier of the second directory.
21、 如权利要求 19所述的终端, 其特征在于, 所述代理元数据中包 括所述文件的标识, 第二目录的标识以及用于表示所述文件已发生移动的 移动标记; 21. The terminal according to claim 19, wherein the proxy metadata includes an identifier of the file, an identifier of the second directory, and a movement mark used to indicate that the file has been moved;
所述第一操作模块具体用于根据所述代理元数据中的移动标记确定所 述文件已发生移动; 根据所述代理元数据中的文件的标识在本地查找所述 文件的元数据; 判断查找到的所述文件的元数据中所述文件的父目录标识 是否为所述第二目录的标识; 若所述文件的父目录标识不是所述第二目录 的标识, 则在查找到的所述文件的元数据中将所述文件设置为隐藏; 若所 述文件的父目录标识是所述第二目录的标识, 则不对所述文件做处理。 The first operation module is specifically configured to determine that the file has moved based on the movement mark in the proxy metadata; to locally search for the metadata of the file based on the identification of the file in the proxy metadata; to determine the search. Whether the parent directory identifier of the file in the metadata of the file is the identifier of the second directory; if the parent directory identifier of the file is not the second directory , the file is set to be hidden in the found metadata of the file; if the parent directory identifier of the file is the identifier of the second directory, the file is not processed.
22、 如权利要求 20所述的终端, 其特征在于, 所述第二操作模块还 用于在查找到所述文件的元数据后, 确定所述文件的状态, 若所述文件处 于隐藏状态, 则在所述文件的元数据中将所述文件更改为显示状态。 22. The terminal according to claim 20, wherein the second operation module is further configured to determine the status of the file after finding the metadata of the file. If the file is in a hidden state, The file is then changed to a display state in the file's metadata.
PCT/CN2014/080993 2013-06-29 2014-06-27 Method and device for synchronizing terminal and server WO2014206346A1 (en)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN201310270933.8 2013-06-29
CN201310270933.8A CN103312489B (en) 2013-06-29 2013-06-29 A kind of terminal carries out synchronize method and apparatus with server

Publications (1)

Publication Number Publication Date
WO2014206346A1 true WO2014206346A1 (en) 2014-12-31

Family

ID=49137300

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2014/080993 WO2014206346A1 (en) 2013-06-29 2014-06-27 Method and device for synchronizing terminal and server

Country Status (2)

Country Link
CN (1) CN103312489B (en)
WO (1) WO2014206346A1 (en)

Families Citing this family (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103312489B (en) * 2013-06-29 2016-12-07 华为技术有限公司 A kind of terminal carries out synchronize method and apparatus with server
CN103500129B (en) * 2013-10-16 2017-08-11 华为技术有限公司 A kind of transmission of backup object, backup method, the manufacturing side, the standby end of calamity and system
CN103595776A (en) * 2013-11-05 2014-02-19 福建网龙计算机网络信息技术有限公司 Distributed type caching method and system
CN104935966A (en) * 2015-06-03 2015-09-23 无锡天脉聚源传媒科技有限公司 Method and device for copying classified video information
CN104994164A (en) * 2015-07-08 2015-10-21 浪潮(北京)电子信息产业有限公司 Method and device for statistics of catalog information
CN107346338B (en) * 2017-06-30 2021-01-01 武汉斗鱼网络科技有限公司 File directory ordering method and device
CN110019208A (en) * 2017-11-14 2019-07-16 中国移动通信有限公司研究院 A kind of data migration method, device and medium
CN110275863B (en) * 2019-06-26 2022-03-25 北京达佳互联信息技术有限公司 File moving method and device and storage medium

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1436413A (en) * 2000-04-10 2003-08-13 捷讯研究有限公司 System and method for pushing information from host system to mobile data communication device
CN1954317A (en) * 2004-05-26 2007-04-25 诺基亚公司 Method, system, computer programs and devices for management of media items
CN103312489A (en) * 2013-06-29 2013-09-18 华为技术有限公司 Method and device for synchronizing terminal and server

Family Cites Families (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102693233B (en) * 2011-03-23 2016-03-30 中兴通讯股份有限公司 A kind of method and device realizing c bookmart

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1436413A (en) * 2000-04-10 2003-08-13 捷讯研究有限公司 System and method for pushing information from host system to mobile data communication device
CN1954317A (en) * 2004-05-26 2007-04-25 诺基亚公司 Method, system, computer programs and devices for management of media items
CN103312489A (en) * 2013-06-29 2013-09-18 华为技术有限公司 Method and device for synchronizing terminal and server

Also Published As

Publication number Publication date
CN103312489B (en) 2016-12-07
CN103312489A (en) 2013-09-18

Similar Documents

Publication Publication Date Title
WO2014206346A1 (en) Method and device for synchronizing terminal and server
CN107861686B (en) File storage method, server and computer readable storage medium
AU2015401229B2 (en) Website access method, apparatus, and website system
US11533220B2 (en) Network-assisted consensus protocol
CN107360234B (en) Computer readable storage medium
CN110311983B (en) Service request processing method, device and system, electronic equipment and storage medium
KR100750142B1 (en) Method and Apparatus for Synchronizing Content with a Collection of Home Devices
CN104301373B (en) Via the synchronous sending out notice of file-sharing service
JP6255138B2 (en) Method, system, and computer-readable storage medium for synchronization and conflict resolution of distributed data
JP6700308B2 (en) Data copy method and device
JP2016105080A (en) Method of updating car navigation map, car navigation device, and system thereof
TWI734744B (en) Method, device and system for synchronizing routing table
US10021181B2 (en) System and method for discovering a LAN synchronization candidate for a synchronized content management system
CN104995902A (en) Methods and systems for seamless network communication between IPV4 and IPV6 devices
WO2009003414A1 (en) A method and device for data synchronization among terminals
WO2012151993A1 (en) Service pushing method and device
TW201432469A (en) Method of file synchronization and electronic device thereof
TW201629792A (en) Method and apparatus for changing configurations
KR20140007363A (en) Site-aware distributed file system access from outside enterprise network
CN103812900A (en) Data synchronization method, device and system
WO2013091449A1 (en) Connecting wireless devices
KR101714821B1 (en) Control apparatus of application mobility in home network
TW201500933A (en) Method for sharing and synchronizing data in local area network
KR20160026138A (en) Rapid sync method for cloud file system and cloud file system using the same
CN110661857B (en) Data synchronization method and device

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 14816611

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

122 Ep: pct application non-entry in european phase

Ref document number: 14816611

Country of ref document: EP

Kind code of ref document: A1