WO2013086842A1 - 一种文件同步方法和装置 - Google Patents

一种文件同步方法和装置 Download PDF

Info

Publication number
WO2013086842A1
WO2013086842A1 PCT/CN2012/076773 CN2012076773W WO2013086842A1 WO 2013086842 A1 WO2013086842 A1 WO 2013086842A1 CN 2012076773 W CN2012076773 W CN 2012076773W WO 2013086842 A1 WO2013086842 A1 WO 2013086842A1
Authority
WO
WIPO (PCT)
Prior art keywords
file
file list
server
synchronization
snapshot
Prior art date
Application number
PCT/CN2012/076773
Other languages
English (en)
French (fr)
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 华为技术有限公司
Priority to ES12856915.9T priority Critical patent/ES2563297T3/es
Priority to KR1020137033562A priority patent/KR20140010187A/ko
Priority to EP12856915.9A priority patent/EP2706719B1/en
Priority to JP2014526366A priority patent/JP5870193B2/ja
Priority to US13/622,660 priority patent/US20130151468A1/en
Publication of WO2013086842A1 publication Critical patent/WO2013086842A1/zh

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
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L65/00Network arrangements, protocols or services for supporting real-time applications in data packet communication
    • H04L65/40Support for services or applications
    • 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/1097Protocols in which an application is distributed across nodes in the network for distributed storage of data in networks, e.g. transport arrangements for network file system [NFS], storage area networks [SAN] or network attached storage [NAS]

Definitions

  • the present invention relates to the field of communications technologies, and in particular, to a file synchronization method and apparatus.
  • BACKGROUND With the development of Internet technologies, more and more users prefer to use file synchronization to manage files on a terminal, which enables users to synchronize file updates to servers in different places and on different terminals in a timely manner, and at the same time facilitate users to Get the latest file information on the server.
  • the terminal After the user updates the file in the terminal synchronization directory, the terminal performs a full scan on the local synchronization directory, and sends each scanned file information to the server for verification to determine the update of the file. Status, such as add or delete, etc. If the file is updated, the file is synced to the server.
  • the drawback of this synchronization is that the two-way synchronization between the terminal and the server cannot be realized, that is, the update of the terminal is synchronized to the server, and the update of the server is synchronized to the terminal, where the update of the server may be an update after the interaction between the server and other terminals, It can be an update that is operated on the server.
  • Embodiments of the present invention provide a file synchronization method and apparatus that can implement two-way synchronization between a device for synchronization and a server.
  • An embodiment of the present invention provides a file synchronization method, including: acquiring a first file list snapshot, where the first file list snapshot includes information of a local file list at the end of the last synchronization; and the first file list snapshot and The information of the local file list is compared, and the second file list snapshot is obtained, where the second file list snapshot includes the current local file list.
  • An embodiment of the present invention provides an apparatus for synchronizing, including: a first acquiring unit, configured to acquire a first file list snapshot, where the first file list snapshot includes information of a local file list at the end of the last synchronization; a second obtaining unit, configured to compare the first file list snapshot with the information of the current local file list, to obtain a second file list snapshot, where the second file list snapshot includes an update of the current local file list a sending unit, configured to send a file list snapshot request to the server, a receiving unit, configured to receive a third file list snapshot sent by the server, where the third file list snapshot includes information of a file list of the server; And a unit, configured to determine, according to the second file list snapshot and the third file list snapshot, an identifier and an operation of the file to be synchronized, and perform file synchronization with the server according to the identifier and operation of the to-be-synchronized file.
  • the second file list snapshot in the embodiment of the present invention includes an update operation of the current local file list
  • the third file list snapshot includes information of the server file list
  • the second The operation of the file to be synchronized determined by the file list snapshot and the third file list snapshot includes both the update operation of the file in the local file list and the update operation of the file in the local file list.
  • the update operation of the files in the server file list so that the two-way synchronization of the device and the server for synchronization can be realized according to the identification and operation of the file to be synchronized.
  • FIG. 1 is a flowchart of a file synchronization method according to an embodiment of the present invention.
  • FIG. 2 is a signaling flowchart of a file synchronization method according to an embodiment of the present invention.
  • FIG. 3 is a structural diagram of an apparatus that can be used for synchronization according to an embodiment of the present invention. detailed description
  • FIG. 1 is a flowchart of a file synchronization method according to an embodiment of the present invention.
  • a terminal is used as a device that can be used for synchronization, that is, an execution body of file synchronization.
  • This embodiment specifically includes:
  • the terminal acquires a first file list snapshot, where the first file list snapshot includes information of a local file list at the end of the last synchronization, and the information refers to information of multiple files in the file list.
  • the file list snapshot refers to the image information of the file list at a time.
  • the file list snapshot mainly includes file list information and file status, and the file status can be set to an initial state.
  • the file is used to reflect the update operation of the file in the file list, thereby determining the operation of the synchronization file after the decision. 102. Compare the first file list snapshot with the current local file list information to obtain a second file list snapshot.
  • the terminal scans the local file list, compares the scanned current local file list information with the information in the first file list snapshot, and obtains an update operation of the local file list relative to the first file list snapshot, the update.
  • the operation refers to an update operation of a file in a file list snapshot, such as local addition, local deletion, or local modification, and the update operation of the local file list is included in the second file list snapshot, where the second file list snapshot may be an update.
  • the first file list snapshot can also be a regenerated file list snapshot.
  • the terminal sends a file list snapshot request to the server to obtain file list information of the server.
  • the terminal receives a third file list snapshot sent by the server, where the third file list snapshot is generated by the server after receiving the file list snapshot request, and includes information of the server file list.
  • the server can perform synchronization operations with other terminals during the last synchronization of the terminal to the current synchronization to send the file list snapshot request to the server, the file information on the server is updated, so the file list information of the server can be Contains updated information.
  • the terminal compares the second file list snapshot with the third file list snapshot to determine an update operation that has been completed in the server file list, and therefore, according to the completed update of the local file list included in the second file list snapshot
  • the operation and the completed update operation of the file list of the server determine the identifier and operation of the file to be synchronized, wherein the operation of the file to be synchronized includes uploading, downloading, renaming or deleting.
  • the terminal determines the operation classification according to the update operation of the local file list included in the second file list snapshot and the update operation of the file list of the server, and classifies according to the operation.
  • the update operation of the local file list and the update operation of the file list of the server are combined to determine the identification and operation of the file to be synchronized.
  • the file is synchronized with the server according to the identifier and operation of the file to be synchronized.
  • the second file list snapshot in this embodiment includes an update operation of the current local file list
  • the third file list snapshot includes information of the server file list, and is determined by the second file list snapshot and the third file list snapshot.
  • the update operation of the file in the local file list is included
  • the update operation of the file in the server file list is included, so that the device and the server for synchronization can be realized according to the identification and operation of the file to be synchronized.
  • FIG. 2 illustrates a signaling flow of a file synchronization method according to an embodiment of the present invention.
  • the terminal is used as a device that can be used for synchronization.
  • This embodiment specifically includes:
  • the terminal sends a login request to the server, where the login request includes a user identifier, where the user identifier may be a username or a password.
  • the login request may further include a terminal identifier.
  • the server may distinguish the terminal according to the terminal identifier.
  • the server After receiving the login request, the server obtains the user identifier in the login request, queries the user database information, verifies the authority of the user identifier, and sends the verification result to the terminal.
  • the server can further risk the terminal identification to distinguish different terminals.
  • the terminal receives the verification result sent by the server, and the verification result may be a login failure or a login success.
  • the terminal can set the synchronization directory, and considering the service requirements, such as the limitation of network traffic, the terminal can set the working mode, wherein the working mode includes one-way synchronization (including one-way upload synchronization and one-way download synchronization).
  • one-way synchronization refers to updating from the local to the server or from the server to the synchronization during the synchronization process; Step refers to the local and server synchronization in both directions; selective synchronization refers to allowing users to selectively synchronize files, such as only synchronizing a subdirectory or a certain type of file.
  • the first file list snapshot includes information about the file list after the last synchronization of the terminal and the server, and can be stored locally on the terminal, so the terminal can directly read the local file.
  • the first file list snapshot may include a file identifier, a file path, a file creation time, a directory, or a file status, where the file identifier may be a file name or other file identifier information; the file status is used to reflect The update operation of the files in the file list.
  • the first file list snapshot may further include a version number, and the version number identifies version information of the file list in the directory to be synchronized between the terminal and the server at the end of the last synchronization.
  • the terminal runs the synchronization for the first time, that is, there is no previous synchronization process, the first file list snapshot does not exist on the terminal, or the read fails even if the first file list snapshot exists on the terminal. For example, if the user loses or is damaged, the terminal needs to directly scan the files and directories in the local synchronization directory and rebuild the first file list snapshot.
  • File ID file path File creation time is the directory file status
  • the first file list snapshot includes information about l.txt, 2.txt, Hello directory, and a.txt file in the Hello directory.
  • Each record includes file identifier, file path, file creation time, whether it is a directory, And the file status, where, in the list of directories, 0 for files, 1 for directories; file status initially set to initial.
  • the terminal scans the local file list and scans related information (such as file identifier and text) Whether the path of the piece, the file creation time, whether it is a directory, or the file status, etc., and the information in the first file list snapshot (such as file identifier, file path, file creation time, whether it is a directory, or file status, etc.) are compared.
  • the second file list snapshot includes an update operation of the local file list.
  • the update operation of each file is recorded in the file state in the second file list snapshot, and the file status is changed from the initial initial state to the update operation, and the update operation is performed.
  • the update operation of the current local file list is recorded in the first file list snapshot, and the updated first file list snapshot is taken as the second file list snapshot.
  • modify the file status of the file in the first file list snapshot if there is information about the file in the first file list snapshot; if the first file list snapshot does not have the file information, the first file list Add a record about the file to the snapshot and set the state of the file to update.
  • the update operation of the terminal includes: deleting the file l.txt, renaming 2.txt to 2-rename.txt, and renaming the Hello directory to Hello-rename, ie the terminal scans to
  • the information about the files and directories in the current synchronization directory is:
  • the terminal scans to the file 2-rename.txt, it finds that there is no record of the file in the first file list snapshot, and then adds the record in the first file list snapshot, and sets the file state to be locally added ( local_add );
  • the terminal scans the file a.txt in the Hello-rename directory, since Hdlo-rename ⁇ a.txt does not record in the first file list snapshot, the record is added to the first file list snapshot, and the file is set.
  • the state is locally added ( local_add ); after the terminal scans all the files in the directory Hello-rename and does not find the record of Hello-rename in the first file list snapshot, add Hello-rename to the first file list snapshot. Record, shape
  • the state is also updated to be locally added ( local_add ).
  • File ID file path File creation time is the directory file status
  • the updated first file list snapshot that is, the second file list snapshot contains the update operation of the files in the local file list.
  • the terminal sends a file list snapshot request to the server to obtain current information of the server file list.
  • the server After receiving the file list snapshot request sent by the terminal, the server generates a third file list snapshot according to the file list information of the server, where the third file list snapshot includes information about the file list of the server, and may specifically include a file identifier, a file path, and a file.
  • the creation time, whether it is a directory, or file status, etc., the initial file status can be initial.
  • the server does not synchronize with other terminals after the last synchronization of the terminal and the synchronization, the information of the file list in the server synchronization directory remains unchanged; if the last synchronization in the terminal After the end of the synchronization, the server synchronizes with other terminals, causing the information of the file in the server synchronization directory to change, and the second file list snapshot contains the update information of the file list. 208. Return to the third file list snapshot.
  • the server sends a third file list snapshot to the terminal.
  • the terminal receives and acquires a third file list snapshot sent by the server.
  • the second comparison and determine the identification and operation of the file to be synchronized.
  • the terminal After obtaining the third file list snapshot, the terminal compares the second file list snapshot with the third file list snapshot to determine an update operation of the server file list, such as server addition, server deletion, or server modification, and therefore, according to the second
  • the update operation of the local file list included in the file list snapshot and the update operation of the file list of the foregoing server determine the identification and operation of the file to be synchronized, wherein the operations of the file to be synchronized include uploading, downloading, renaming or deleting.
  • the third file list snapshot may further include a version number, where the version number identifies version information at the last synchronization end of the file list in the server synchronization directory, if the server is in the current synchronization and the previous synchronization, and other terminals If the synchronization operation causes the server's file list to be updated, the version number will change.
  • the first file list snapshot on the terminal may further include a version number, which is the local synchronization directory at the end of the last synchronization.
  • the version information of the file list because the file list in the local synchronization directory and the file list information in the server synchronization directory are the same at the end of the last synchronization, the version number is recorded at the end of the last synchronization of the file list in the server synchronization directory.
  • Version information that is, if the server does not synchronize with other terminals, the version number in the first file list snapshot is the same as the version number in the third file list snapshot.
  • the terminal compares the version number in the first file list snapshot on the terminal with the version number in the third file list snapshot obtained from the server. If the two version numbers are the same, indicating that between the current synchronization and the last synchronization, The server has not synchronized with other terminals, that is, the file list of the server synchronization directory has not changed. At this time, the terminal can determine the identification and operation of the file to be synchronized according to the update operation of the file list in the second file list snapshot.
  • the terminal first classifies the update operation in the second file list snapshot, and determines the operation. For classification, such as adding local_add locally, deleting local_dd locally, or modifying local_modify locally; since some file states are logically mergable, the file operation is determined directly according to the file state according to the relevant merge rule. For example, for the local file renaming operation, the second file list snapshot will have the local delete local_del operation of the original file, and the locally added local_add operation of the renamed file will be combined with the original file and renamed. The related information of the file is compared to determine that the local_del and local_add are merged, and the renameFile operation is renamed to the file.
  • classification such as adding local_add locally, deleting local_dd locally, or modifying local_modify locally; since some file states are logically mergable, the file operation is determined directly according to the file state according to the relevant merge rule.
  • the second file list snapshot will have the local delete local_del operation
  • the request for the renameFile operation on the original file is sent to the server, and the server only needs to rename the original file.
  • Implement synchronization with the file on the terminal If it is not merged, it needs to send a request to delete the original file operation to the server, and then send a request to increase the renamed file, and the server needs to delete the original file according to the operation of deleting the original file, and then rename the file according to the addition.
  • the terminal determines the identification and operation of the file to be synchronized. Specifically, after comparing the second file list snapshot and the third file list snapshot, the terminal first determines an update operation of the server file list, and then updates the file list according to the second file list snapshot and the server file list update. Operation, determining the identification and operation of the file to be synchronized in the same way as the above version number, and determining the identification and operation of the file to be synchronized in this case.
  • this embodiment only enumerates the merge rules and file operations of some single orders.
  • complex file operations such as file modification
  • the terminal needs to determine the modified file, and the user decides which file to keep and which file to delete.
  • the terminal sends a file synchronization request to the server, where the synchronization request includes operation information of the file to be synchronized, and the server receives the file synchronization request, and obtains the operation information carried therein, thereby synchronizing the server.
  • the files in the directory are related to the operation. Synchronize the file list with the terminal synchronization directory. After the synchronization is completed, the update of the terminal file list will be synchronized to the server. Similarly, the update of the server's file list will be synchronized to the terminal, that is, the two-way synchronization between the terminal and the server is finally realized.
  • the server sends the server to the terminal and other The terminal performs the state of file synchronization, so the terminal will receive the state that the server is synchronizing files with other terminals at this time, and suspend the file synchronization operation with the server.
  • the file synchronization request may be sent to the server at a certain time (such as half a minute, etc.); or, the terminal receives the message that the server sent by the server is in an idle state, and then sends the message to the server.
  • File synchronization request file synchronization with the server.
  • sets the identifier and operation of the file to be synchronized generated above as:
  • HTTP HyperText Transfer Protocol
  • the server After receiving the above HTTP request, the server deletes the files l.txt and 2.txt in the directory to be synchronized in the server according to the deleted file (remakefile) l.txt and removefile 2.txt information carried in the request. For other files and operations, the terminal will send a similar file synchronization request to complete the synchronization with the server.
  • the terminal After the file synchronization process is successfully performed in the synchronization directory of the terminal and the server, the terminal further stores a snapshot of the file list in the server or the terminal synchronization directory (the server and the file list in the terminal synchronization directory are consistent), as the first file list snapshot in the next synchronization. And, the version number of the first file list snapshot is regenerated, and the version number of the file list in the server synchronization directory is also updated to the regenerated version number to indicate the consistency of the file list in the terminal and the server synchronization directory.
  • the terminal determines the identifier and operation of the file to be synchronized through two comparisons, and synchronizes with the server according to the identifier and operation of the file to be synchronized.
  • the terminal according to the file to be synchronized The operation sends a corresponding operation request to the server, such as an upload request, a download request, a rename request, or a delete request.
  • the server can perform corresponding processing according to the received related operation request, and the server does not need to determine to be synchronized during the entire synchronization process.
  • the identification and operation of the file therefore, this synchronization method can effectively alleviate the processing load of the server.
  • the second file list snapshot in this embodiment includes an update operation of the current local file list
  • the third file list snapshot includes information of the server file list, and is determined by the second file list snapshot and the third file list snapshot.
  • the update operation of the file in the local file list is included
  • the update operation of the file in the server file list is included, so that the device and the server for synchronization can be realized according to the identification and operation of the file to be synchronized.
  • FIG. 3 depicts an apparatus for synchronizing provided by another embodiment of the present invention, including:
  • the first obtaining unit 308 is configured to acquire a first file list snapshot, where the first file list snapshot includes information of a local file list at the end of the last synchronization.
  • the second obtaining unit 309 is configured to compare the first file list snapshot acquired by the first obtaining unit 308 with the current local file list to obtain a second file list snapshot, where the second file list snapshot includes an update of the current local file list.
  • the device that can be used for synchronization scans the local file list, compares the information related to the scanned file with the information in the first file list snapshot, and determines the change of the current file relative to the corresponding information in the first file list snapshot, and A second file list snapshot is generated, and the second file list snapshot may be an updated first file list snapshot or a regenerated snapshot.
  • the sending unit 310 is configured to send a file list snapshot request to the server to obtain current information of the server file list.
  • the receiving unit 311 is configured to receive a third file list snapshot sent by the server, where the third file list snapshot includes information of a file list of the server.
  • the synchronization unit 312 is configured to determine, according to the second file list snapshot acquired by the second obtaining unit 309 and the third file list snapshot received by the receiving unit 311, the identifier and operation of the file to be synchronized, and according to the identifier and operation of the file to be synchronized and the server File synchronization.
  • the device that can be used for synchronization may be a terminal that performs data interaction with the server.
  • FIG. 3 further illustrates the structure of a terminal according to an embodiment of the present invention.
  • the terminal may include at least one processor 301 and at least one network interface. 304, a memory 305 and at least one communication bus 302 for enabling connection communication between these components.
  • the terminal can also include a user interface 303 for enabling interaction with the user.
  • Memory 305 can include:
  • the application unit 307 is configured to determine, according to the obtained update operation of the local file list and the update operation of the file list of the server, the file identifier and operation to be synchronized, and perform file synchronization with the server according to the file identifier and operation to be synchronized.
  • the application unit 307 specifically includes:
  • the first obtaining unit 308 is configured to acquire a first file list snapshot, where the first file list snapshot includes information of a local file list at the end of the last synchronization.
  • the second obtaining unit 309 is configured to compare the first file list snapshot acquired by the first obtaining unit 308 with the current local file list to obtain a second file list snapshot, where the second file list snapshot includes an update of the current local file list. operating. Specifically, the terminal scans the local file list, compares the information related to the scanned file with the information in the first file list snapshot, determines the change of the current file relative to the corresponding information in the first file list snapshot, and generates a second file.
  • the list snapshot, the second file list snapshot may be the updated first file list snapshot, or may be a regenerated snapshot.
  • the sending unit 310 is configured to send a file list snapshot request to the server to obtain current information of the server file list.
  • the receiving unit 311 is configured to receive a third file list snapshot sent by the server, where the third file list snapshot includes information of a file list of the server.
  • the synchronization unit 312 is configured to determine, according to the second file list snapshot acquired by the second obtaining unit 309 and the third file list snapshot received by the receiving unit 311, the identifier and operation of the file to be synchronized, and according to the identifier and operation of the file to be synchronized and the server File synchronization.
  • the synchronization unit 312 is configured to determine, according to the second file list snapshot acquired by the second obtaining unit 309 and the third file list snapshot received by the receiving unit 311, an update operation of the file list of the server, and according to the update operation of the local file list. And the update operation of the file list of the server, determining the identifier and operation of the file to be synchronized; in addition, the synchronization unit 312 may be further configured to suspend the server when the server sent by the receiving server is in a state of synchronizing files with other terminals. File synchronization operation.
  • the method may further include:
  • the setting unit 313 is configured to set an operation mode, where the working mode includes one-way synchronization, two-way synchronization, or selective synchronization. After the setting unit 313 sets a specific working mode, the synchronization unit 312 cooperates with the server according to the working mode set by the setting unit 313. File synchronization.
  • the second file list snapshot in this embodiment includes an update operation of the current local file list
  • the third file list snapshot includes information of the server file list, and is determined by the second file list snapshot and the third file list snapshot.
  • both local file columns are included
  • the update operation of the file in the table further includes the update operation of the file in the server file list, so that the two-way synchronization of the device and the server for synchronization can be realized according to the identification and operation of the file to be synchronized.
  • the above terminal may participate in the method shown in FIG. 1 or FIG. 2, and the workflow thereof will not be described herein.
  • the storage medium may be a magnetic disk, an optical disk, a read only memory (ROM: Read Random Memory), or a random access memory (RAM).
  • ROM Read Random Memory
  • RAM random access memory

Landscapes

  • Engineering & Computer Science (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Signal Processing (AREA)
  • Multimedia (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)
  • Information Transfer Between Computers (AREA)

Abstract

本发明涉及通信技术领域,具体涉及文件同步方法及装置,其中文件同步方法包括:获取第一文件列表快照,第一文件列表快照包含上一次同步结束时本地文件列表的信息;将第一文件列表快照和当前本地文件列表的信息进行比较,获取第二文件列表快照,第二文件列表快照包含当前本地文件列表的更新操作;向服务器发送文件列表快照请求;接收服务器发送的第三文件列表快照,第三文件列表快照包含服务器的文件列表的信息;根据第二文件列表快照和第三文件列表快照确定待同步文件的标识和操作,并根据待同步文件的标识和操作与服务器进行文件同步。使用本发明,能够实现用于同步的装置和服务器之间的双向同步,提高用户体验。

Description

一种文件同步方法和装置 技术领域
本发明涉及通信技术领域, 具体涉及文件同步方法和装置。 背景技术 随着互联网技术的发展, 越来越多的用户喜欢使用文件同步来管理终端 上的文件, 这可以使得用户在不同地方和不同终端上及时将文件的更新同步 到服务器, 同时方便用户从服务器上获取最新的文件信息。
现有的文件同步技术中, 用户对终端同步目录下的文件进行更新操作后, 终端对本地同步目录进行一次全扫描, 将扫描到的每个文件信息发送到服务 器验证, 以确定该文件的更新状态, 比如增加或删除等, 如果该文件是更新 的, 则将文件同步到服务器。 这种同步的缺陷表现在不能实现终端和服务器 的双向同步, 即将终端的更新同步到服务器, 同时将服务器的更新同步到终 端, 这里服务器的更新可以是服务器和其他终端发生交互后的更新, 也可以 是在服务器上操作的更新。
发明内容 本发明的实施例提供了文件同步方法和装置, 可以实现用于同步的装置 和服务器之间的双向同步。 本发明的实施例提供了一种文件同步方法, 包括: 获取第一文件列表快照, 所述第一文件列表快照包含上一次同步结束时 本地文件列表的信息; 将所述第一文件列表快照和当前所述本地文件列表的信息进行比较, 获 取第二文件列表快照, 所述第二文件列表快照包含当前所述本地文件列表的 更新操作; 向服务器发送文件列表快照请求; 接收所述服务器发送的第三文件列表快照, 所述第三文件列表快照包含 所述服务器的文件列表的信息; 根据所述第二文件列表快照和所述第三文件列表快照确定待同步文件的 标识和操作, 并根据所述待同步文件的标识和操作与所述服务器进行文件同 步。 本发明的实施例提供了一种可用于同步的装置, 包括: 第一获取单元, 用于获取第一文件列表快照, 所述第一文件列表快照包 含上一次同步结束时本地文件列表的信息; 第二获取单元, 用于将所述第一文件列表快照和当前所述本地文件列表 的信息进行比较, 获取第二文件列表快照, 所述第二文件列表快照包含当前 所述本地文件列表的更新操作; 发送单元, 用于向服务器发送文件列表快照请求; 接收单元, 用于接收所述服务器发送的第三文件列表快照, 所述第三文 件列表快照包含所述服务器的文件列表的信息; 同步单元, 用于根据所述第二文件列表快照和所述第三文件列表快照确 定待同步文件的标识和操作, 并根据所述待同步文件的标识和操作与所述服 务器进行文件同步。
从本发明实施例提供的以上技术方案可以看出, 由于本发明实施例中的 第二文件列表快照包含当前本地文件列表的更新操作, 第三文件列表快照包 含服务器文件列表的信息, 通过第二文件列表快照和第三文件列表快照确定 的待同步文件的操作中, 既包括了本地文件列表中文件的更新操作, 又包括 了服务器文件列表中文件的更新操作, 因此根据待同步文件的标识和操作就 可以实现用于同步的装置和服务器的双向同步。
附图说明
为了更清楚地说明本发明实施例或现有技术中的技术方案, 下面将对实 施例或现有技术描述中所需要使用的附图作一筒单地介绍, 显而易见地, 下 面描述中的附图仅仅是本发明的一些实施例, 对于本领域普通技术人员来讲, 在不付出创造性劳动性的前提下, 还可以根据这些附图获得其他的附图。
图 1为本发明一个实施例提供的一种文件同步方法的流程图。
图 2为本发明一个实施例提供的一种文件同步方法的信令流程图。
图 3为本发明一个实施例提供的一种可用于同步的装置的结构图。 具体实施方式
下面将结合本发明实施例中的附图, 对本发明实施例中的技术方案进行 清楚、 完整地描述。 显然, 所描述的实施例仅仅是本发明一部分实施例, 而 不是全部的实施例。 基于本发明中的实施例, 本领域普通技术人员在没有做 出创造性劳动前提下所获得的所有其他实施例, 都属于本发明保护的范围。
图 1描述了本发明一个实施例提供的一种文件同步方法的流程, 本实施例 中, 优选的, 以终端作为可用于同步的装置, 即文件同步的执行主体。 该实 施例具体包括:
101、 获取第一文件列表快照。
具体地, 终端获取第一文件列表快照, 该第一文件列表快照包含上一次 同步结束时本地文件列表的信息, 该信息是指文件列表中多个文件的信息。 在本发明的实施例中, 文件列表快照是指某时文件列表的映像信息。 其中, 文件列表快照主要包含文件列表信息和文件状态, 文件状态可以设置一个初 始状态, 后期比较过程中, 用来反映文件列表中文件的更新操作, 从而决定 后期待同步文件的操作。 102、 将第一文件列表快照和当前本地文件列表的信息进行比较, 获取第 二文件列表快照。
具体地, 终端扫描本地文件列表, 将扫描到的当前本地文件列表的信息 和第一文件列表快照中的信息进行比较, 获取本地文件列表相对于第一文件 列表快照已经完成的更新操作, 该更新操作是指文件列表快照中文件的更新 操作, 比如本地添加、 本地删除或本地修改等, 并将本地文件列表的更新操 作包含在第二文件列表快照中, 其中, 第二文件列表快照可以是更新的第一 文件列表快照, 也可以是一个重新生成的文件列表快照。
103、 向服务器发送文件列表快照请求。
具体的, 终端向服务器发送文件列表快照请求, 以获取服务器的文件列 表信息。
104、 接收服务器发送的第三文件列表快照。
具体的, 终端接收服务器发送的第三文件列表快照, 第三文件列表快照 是服务器在接收到文件列表快照请求后生成的, 并且包含服务器的文件列表 的信息。
另外, 由于在终端上一次同步结束后到本次同步向服务器发送文件列表 快照请求期间, 服务器可以与其他终端进行同步操作, 从而导致服务器上的 文件信息被更新了, 因此服务器的文件列表信息可以包含更新信息。
105、 根据第二文件列表快照和第三文件列表快照确定待同步文件的标识 和操作, 并根据待同步文件的标识和操作与服务器进行文件同步。
具体的, 终端将第二文件列表快照和第三文件列表快照进行比较, 确定 服务器的文件列表中已经完成的更新操作, 因此, 根据第二文件列表快照中 包含的本地文件列表的已经完成的更新操作和上述服务器的文件列表的已经 完成的更新操作, 确定待同步文件的标识和操作, 其中待同步文件的操作包 括上传、 下载、 重命名或删除等。
优选的, 终端根据第二文件列表快照中包含的本地文件列表的更新操作 和上述服务器的文件列表的更新操作, 确定操作分类, 并按照该操作分类, 对本地文件列表的更新操作和服务器的文件列表的更新操作进行合并, 确定 待同步文件的标识和操作。
在终端确定待同步文件的标识和操作后, 根据待同步文件的标识和操作 与服务器进行文件同步操作。
从上可知, 本实施例中的第二文件列表快照包含当前本地文件列表的更 新操作, 第三文件列表快照包含服务器文件列表的信息, 通过第二文件列表 快照和第三文件列表快照确定的待同步文件的操作中, 既包括了本地文件列 表中文件的更新操作, 又包括了服务器文件列表中文件的更新操作, 因此根 据待同步文件的标识和操作就可以实现用于同步的装置和服务器的双向同 步。 图 2描述了本发明一个实施例提供的一种文件同步方法的信令流程, 本是 实施例中, 优选的, 以终端作为可用于同步的装置。 该实施例具体包括:
201、 发送登录请求。
具体地, 终端向服务器发送登录请求, 该登录请求包含用户标识, 其中, 用户标识可以是用户名或密码。 该登录请求还可以进一步包括终端标识, 当 多个终端利用同一用户名同时登录时, 服务器可以根据终端标识来区分终端。
202、 登录验证。
具体地, 服务器接收到登录请求后, 获取登录请求中的用户标识, 通过 查询用户数据库信息, 验证用户标识的权限, 并发送验证结果给终端。 服务 器还可以进一步对终端标识进行险证, 以区分不同的终端。
203、 登录响应。
具体地, 终端接收服务器发送的验证结果, 该验证结果可以为登录失败 或登录成功。 当登录成功后, 终端可以设置同步目录, 同时考虑到业务需求, 比如网络流量的限制等, 终端可以设置工作模式, 其中, 工作模式包括单向 同步(包括单向上传同步和单向下载同步)、双向同步或者选择性同步,单向同 步是指在同步过程中由本地向服务器或者由服务器向同步进行更新; 双向同 步是指本地和服务器双向进行同步; 选择性同步, 是指允许用户有选择地同 步文件, 如仅仅同步某一个子目录或者某类文件等。
204、 获取第一文件列表快照。
具体地, 终端登录成功后, 获取第一文件列表快照, 第一文件列表快照 包含终端和服务器上一次同步结束后文件列表的信息, 可以存储在终端本地 上, 因此终端可以直接在本地读取第一文件列表快照。 另外, 第一文件列表 快照可以包含文件标识、 文件路径、 文件创建时间、 是否为目录, 或文件状 态, 其中, 文件标识可以是文件名, 也可以是其他文件标志信息; 文件状态 用来反映针对文件列表中的文件的更新操作。 另外, 第一文件列表快照还可 以进一步包括版本号, 该版本号标识的是上一次同步结束时, 终端和服务器 的待同步目录下文件列表的版本信息。
需要说明的是, 如果终端是第一次运行同步, 即不存在上一次的同步过 程, 则终端上不存在第一文件列表快照, 或者, 即使终端上存在第一文件列 表快照, 但是读取失败, 比如丢失或损坏, 都需要终端直接扫描本地同步目 录下文件与目录, 重新构建第一文件列表快照。
例如, 下面给出一个第一文件列表快照的示例:
文件标识文件路径 文件创建时间是否为目录 文件状态
1. txt \ 1319162967 Oinitial
2. txt \ 1319163850 0 initial
Hello \ 1319199057 1 initial
a.txt \Hello 1313916412 0 initial
该示例中, 第一文件列表快照包含 l.txt、 2.txt、 Hello目录和 Hello目录下 a.txt文件的相关信息, 每条记录包括文件标识、 文件路径、 文件创建时间、 是 否为目录、 和文件状态, 其中, 在是否为目录一列, 0代表文件, 1代表目录; 文件状态初始设置为 initial。
205、 第一次比较, 并获取第二文件列表快照。
终端扫描本地文件列表, 将扫描到文件的相关信息 (比如文件标识、 文 件路径、 文件创建时间、 是否为目录, 或文件状态等)和第一文件列表快照 中的信息 (比如文件标识、 文件路径、 文件创建时间、 是否为目录, 或文件 状态等)进行比较, 判断当前文件相对于第一文件列表快照中对应信息的变 化情况, 并生成第二文件列表快照, 第二文件列表快照可以是更新的第一文 件列表快照, 也可以是一个重新生成的快照。
第二文件列表快照包含本地文件列表的更新操作, 优选的, 将每个文件 的更新操作记录在第二文件列表快照中的文件状态, 此时文件状态由初始 initial状态变为更新操作, 更新操作包括本地添加、 本地删除或本地修改等。
可选的, 将当前本地文件列表的更新操作记录在第一文件列表快照中, 即将更新后的第一文件列表快照作为第二文件列表快照。 具体的, 如果第一 文件列表快照中有对应文件的信息, 则修改第一文件列表快照中关于该文件 的文件状态; 如果第一文件列表快照中没有该文件的信息, 则在第一文件列 表快照中增加关于该文件的记录, 并设置该文件的状态为更新操作。
例如, 仍以前面给出的示例继续, 并假设终端的更新操作包括: 删除文 件 l.txt, 重命名 2.txt为 2-rename.txt, 重命名 Hello目录为 Hello -rename , 即终端 扫描到当前同步目录下的文件和目录的信息为:
文件标识文件路径 文件创建时间是否为目录
2-rename.txt \ 1319163850 0
Hello-rename\ 1319199057 1
a.txt \Hello-rename 1313916412 0
终端扫描到文件 2-rename.txt时, 发现在第一文件列表快照中没有该文件 的记录, 则在第一文件列表快照中添加该条记录, 并设置该文件状态为本地 添加 ( local_add ) ; 终端扫描到 Hello-rename目录下的文件 a.txt时, 由于 Hdlo-rename\a.txt在第一文件列表快照中没有记录, 则在第一文件列表快照中 添加该条记录, 并设置该文件的状态为本地添加 ( local_add ); 终端扫描完目 录 Hello-rename下的所有文件后, 也没有在第一文件列表快照中找到 Hello-rename的记录, 则在第一文件列表快照中添加 Hello-rename的记录, 状 态也更新为本地添加 ( local—add )。
在扫描完同步目录下当前的文件与目录后, 第一文件列表快照中没有更 新状态的记录全部标记为本地删除(local_dd ), 因此, 第一次比较结束后, 更新后的第一文件列表快照中包含的变化信息为:
文件标识文件路径 文件创建时间是否为目录 文件状态
1. txt \ 1319162967 0 local—del
2. txt \ 1319163850 0 local—del
Hello \ 1319199057 1 local—del
a.txt \Hello 1313916412 0 local—del
2-rename.txt \ 1319163850 0 local—add
Hello-rename\ 1319199057 1 local—add
a.txt \Hello-reanme 1313916412 0 local_add
经过第一次比较以后, 更新后的第一文件列表快照, 即第二文件列表快 照中包含本地文件列表中文件的更新操作。
206、 发送文件列表快照请求。
具体地, 终端向服务器发送文件列表快照请求, 以获取服务器文件列表 当前的信息。
207、 生成第三文件列表快照。
具体的, 服务器接收终端发送的文件列表快照请求后, 根据服务器的文 件列表信息生成第三文件列表快照, 第三文件列表快照包含服务器的文件列 表的信息, 具体可以包含文件标识、 文件路径、 文件创建时间、 是否为目录、 或文件状态等, 初始的文件状态可以为 initial状态。
需要说明的是, 如果在终端的上一次同步结束之后到这次同步之间, 服 务器没有与其他终端进行过同步操作, 则服务器同步目录下文件列表的信息 不变; 如果在终端的上一次同步结束之后到这次同步之间, 服务器与其他终 端进行过同步操作, 导致服务器同步目录下文件的信息发生了变化, 则第二 文件列表快照包含了文件列表的更新信息。 208、 返回第三文件列表快照。
具体的, 服务器在生成第三文件列表快照后, 向终端发送第三文件列表 快照。
209、 获取第三文件列表快照。
具体地, 终端接收并获取服务器发送的第三文件列表快照。
210、 第二次比较, 并确定待同步文件的标识和操作。
终端获取第三文件列表快照后, 将第二文件列表快照和第三文件列表快 照进行比较, 确定服务器的文件列表的更新操作, 比如服务器增加、 服务器 删除或服务器修改等操作, 因此, 根据第二文件列表快照中包含的本地文件 列表的更新操作和上述服务器的文件列表的更新操作, 确定待同步文件的标 识和操作, 其中待同步文件的操作包括上传、 下载、 重命名或删除等。
具体的, 第三文件列表快照可以进一步包含版本号, 该版本号标识的是 服务器同步目录下文件列表上一次同步结束时的版本信息, 如果服务器在本 次同步与上一次同步之前, 与其他终端进行过同步操作导致服务器的文件列 表发生了更新, 则版本号会发生改变; 同样的, 终端上的第一文件列表快照 可以进一步包含版本号, 该版本号标识是上一次同步结束时本地同步目录下 文件列表的版本信息, 由于上一次同步结束时, 本地同步目录下的文件列表 和服务器同步目录下的文件列表信息一致, 因此该版本号记录的也是服务器 同步目录下文件列表上一次同步结束时的版本信息, 即如果服务器没有与其 他终端进行同步操作, 则第一文件列表快照中的版本号和第三文件列表快照 中的版本号相同。
终端将终端上的第一文件列表快照中的版本号和从服务器获取的第三文 件列表快照中的版本号进行比较, 如果两个版本号相同, 表明在本次同步和 上次同步之间, 服务器没有与其他终端进行过同步操作, 即服务器同步目录 的文件列表没有发生变化, 此时, 终端根据第二文件列表快照中文件列表的 更新操作就可以确定待同步文件的标识和操作。
具体的, 终端首先将第二文件列表快照中的更新操作进行分类, 确定操 作分类, 比如本地添加 local_add、 本地删除 local_dd或本地修改 local_modify 等; 由于有些文件状态在逻辑上是可以合并的, 因此根据相关合并规则, 对 直接根据文件状态确定文件操作。 比如, 对本地文件的重命名操作, 第二文 件列表快照中会有原文件的本地删除 local_del操作, 同时会有重命名后文件的 本地添加 local_add操作,此时就可以结合原文件和重命名后文件的相关信息进 行比较确定对 local_del和 local_add进行合并, 确定为文件重命名 renameFile操 作, 此时向服务器发送对原文件进行 renameFile操作的请求, 而服务器也只用 对原文件进行重命名操作即可实现与终端上该文件的同步。 如果不合并, 则 需要向服务器发送先删除原文件操作的请求, 再发送增加重命名后文件的请 求, 而服务器则需要先根据删除原文件的操作请求删除原文件, 然后又根据 增加重命名后文件的请求, 接收终端上传的重命名后的文件。 因此, 合并文 件状态可以提高文件的同步效率。
如果两个版本号不相同, 表明在本次同步和上次同步之间, 服务器与其 他终端进行过同步操作, 即服务器同步目录的文件列表发生了变化, 此时, 终端根据第二文件列表快照和第三文件列表快照确定待同步文件的标识和操 作。 具体的, 终端将第二文件列表快照和第三文件列表快照进行比较后, 首 先确定服务器的文件列表的更新操作, 再根据第二文件列表快照中文件列表 的更新操作和服务器的文件列表的更新操作, 以与上述版本号相同时确定待 同步文件的标识和操作同样的方法, 确定此种情况待同步文件的标识和操作。
另外, 本实施例仅列举了一些筒单的合并规则和文件操作, 对于复杂的 文件操作, 比如, 文件修改, 则需要终端确定修改文件, 由用户决定保留哪 一个文件, 删除哪一个文件。
211、 根据待同步文件的标识和操作, 与服务器进行文件同步。
具体地, 终端确定待同步文件的标识和操作后, 向服务器发送文件同步 请求, 该同步请求包含着待同步文件的操作信息, 服务器接收文件同步请求, 获取其中携带的操作信息, 从而对服务器同步目录下的文件进行相关操作, 实现与终端同步目录下文件列表的同步。 同步完成后, 终端文件列表的更新 将会被同步到服务器, 同样, 服务器的文件列表的更新也将会被同步到终端, 即最终实现终端和服务器的双向同步。
需要说明的是, 终端在向服务器发送文件同步请求后, 如果服务器正在 与其他终端进行文件同步操作, 即服务器处于正在与其他终端进行文件同步 的状态, 则服务器会向该终端发送服务器正在与其他终端进行文件同步的状 态, 所以终端此时将会接收到服务器正在与其他终端进行文件同步的状态, 并暂停与服务器的文件同步操作。 进一步, 终端暂停与服务器的文件同步操 作后, 可以每隔一定的时间 (比如半分钟等)再向服务器发送文件同步请求; 或者, 终端接收服务器发送的服务器处于空闲状态的消息, 再向服务器发送 文件同步请求, 与服务器进行文件同步操作。
例如, ^^设上述生成的待同步文件的标识和操作为:
文件标识操作
1.txt removefile
2.txt renamefile
1.txt和 2.txt为删除文件操作, 则终端向服务器发送如下所示的超文本传输 协议(HTTP: HyperText Transfer Protocol )请求:
POST http://syncbox.dbank.com/app/pc/disk.removefile.php
HTTP/1.1 NSP-Auth:AccessToken ClientID=3d4e901399d4c0a9aeae4727
Host: syncbox.dbank.com
Path=%2F&files=[" 1 %2Etxt"]
HTTP/1.1 200 ok
{"action": "true", "successList":[{"name": "l.txt"}]}
POST http://syncbox.dbank.com/app/pc/disk.removefile.php
HTTP/1.1 NSP-Auth:AccessToken ClientID=3d4e901399d4c0a9aeae4727
Host: syncbox.dbank.com Path=%2F&files=[" 1 %2Etxt"]
HTTP/1.1 200 ok
{"action": "true", "successList":[{"name": "2.txt"}]}
服务器接收上述的 HTTP请求后,根据请求中携带的删除文件( removefile ) l.txt和 removefile 2.txt信息,将服务器待同步目录中的文件 l.txt和 2.txt删掉。对 于其他的文件及操作, 终端会发送类似的文件同步请求, 完成与服务器的同 步。
终端和服务器同步目录下文件同步处理成功后, 终端进一步存储服务器 或终端同步目录下文件列表的快照 (此时服务器和终端同步目录下文件列表 一致), 作为下一次同步时的第一文件列表快照, 并且, 该第一文件列表快照 的版本号是重新生成的, 服务器同步目录下文件列表的版本号也更新为该重 新生成的版本号, 以表示终端和服务器同步目录下文件列表的一致性。
从本实施例可以看出, 终端通过两次比较确定了待同步文件的标识和操 作, 并根据待同步文件的标识和操作与服务器进行同步, 在具体的同步过程 中, 终端根据待同步文件的操作向服务器发送相应的操作请求, 比如上传请 求、 下载请求、 重命名请求或删除请求等, 服务器根据接收的相关的操作请 求做相应的处理即可, 服务器在整个同步过程中不需要确定待同步文件的标 识和操作, 因此, 该种同步方法可以有效的减轻服务器的处理负荷。
从上可知, 本实施例中的第二文件列表快照包含当前本地文件列表的更 新操作, 第三文件列表快照包含服务器文件列表的信息, 通过第二文件列表 快照和第三文件列表快照确定的待同步文件的操作中, 既包括了本地文件列 表中文件的更新操作, 又包括了服务器文件列表中文件的更新操作, 因此根 据待同步文件的标识和操作就可以实现用于同步的装置和服务器的双向同 步。 相应的, 图 3描述了本发明的另一个实施方式提供的一个可用于同步的装 置, 包括: 第一获取单元 308, 用于获取第一文件列表快照, 第一文件列表快照包含 上一次同步结束时本地文件列表的信息。
第二获取单元 309, 用于将第一获取单元 308获取的第一文件列表快照和 当前本地文件列表的信息进行比较, 获取第二文件列表快照, 第二文件列表 快照包含当前本地文件列表的更新操作。 具体的, 可用于同步的装置扫描本 地文件列表, 将扫描到文件的相关信息和第一文件列表快照中的信息进行比 较, 判断当前文件相对于第一文件列表快照中对应信息的变化情况, 并生成 第二文件列表快照, 第二文件列表快照可以是更新的第一文件列表快照, 也 可以是一个重新生成的快照。
发送单元 310, 用于向服务器发送文件列表快照请求, 以获取服务器文件 列表当前的信息。
接收单元 311 , 用于接收服务器发送的第三文件列表快照, 第三文件列表 快照包含服务器的文件列表的信息。
同步单元 312, 用于根据第二获取单元 309获取的第二文件列表快照和接 收单元 311接收的第三文件列表快照确定待同步文件的标识和操作, 并根据待 同步文件的标识和操作与服务器进行文件同步。
上述可用于同步的装置可以是一种与服务器进行数据交互的终端, 图 3又 描述了本发明一个实施例提供的一种终端的结构, 该终端可以包括至少一个 处理器 301 , 至少一个网络接口 304, 存储器 305和至少一个通信总线 302, 用 于实现这些组件之间的连接通信。 该终端还可以包括用户接口 303 , 用于实现 与用户交互。 存储器 305可以包括:
操作系统 306, 用于处理各种基础的系统服务和执行基于硬件的任务。 应用单元 307, 用于根据获取的本地文件列表的更新操作和服务器的文件 列表的更新操作, 确定待同步的文件标识和操作, 并根据待同步的文件标识 和操作与服务器进行文件同步。 应用单元 307具体包括:
第一获取单元 308, 用于获取第一文件列表快照, 第一文件列表快照包含 上一次同步结束时本地文件列表的信息。 第二获取单元 309, 用于将第一获取单元 308获取的第一文件列表快照和 当前本地文件列表的信息进行比较, 获取第二文件列表快照, 第二文件列表 快照包含当前本地文件列表的更新操作。 具体的, 终端扫描本地文件列表, 将扫描到文件的相关信息和第一文件列表快照中的信息进行比较, 判断当前 文件相对于第一文件列表快照中对应信息的变化情况, 并生成第二文件列表 快照, 第二文件列表快照可以是更新的第一文件列表快照, 也可以是一个重 新生成的快照。
发送单元 310, 用于向服务器发送文件列表快照请求, 以获取服务器文件 列表当前的信息。
接收单元 311 , 用于接收服务器发送的第三文件列表快照, 第三文件列表 快照包含服务器的文件列表的信息。
同步单元 312, 用于根据第二获取单元 309获取的第二文件列表快照和接 收单元 311接收的第三文件列表快照确定待同步文件的标识和操作, 并根据待 同步文件的标识和操作与服务器进行文件同步。
具体的, 同步单元 312用于根据第二获取单元 309获取的第二文件列表快 照和接收单元 311接收的第三文件列表快照, 确定服务器的文件列表的更新操 作, 并且根据本地文件列表的更新操作和服务器的文件列表的更新操作, 确 定待同步文件的标识和操作; 另外, 所述同步单元 312, 还可以用于当接收服 务器发送的服务器正在与其他终端进行文件同步的状态时, 暂停与服务器的 文件同步操作。
在本发明的另一个实施例中, 还可以包括:
设置单元 313 , 用于设置工作模式, 工作模式包括单向同步、 双向同步或 选择性同步等, 在设置单元 313设置具体的工作模式后, 同步单元 312根据设 置单元 313设置的工作模式, 与服务器进行文件同步。
从上可知, 本实施例中的第二文件列表快照包含当前本地文件列表的更 新操作, 第三文件列表快照包含服务器文件列表的信息, 通过第二文件列表 快照和第三文件列表快照确定的待同步文件的操作中, 既包括了本地文件列 表中文件的更新操作, 又包括了服务器文件列表中文件的更新操作, 因此根 据待同步文件的标识和操作就可以实现用于同步的装置和服务器的双向同 步。
上述终端可以参与执行图 1或者图 2所示的方法, 其工作流程在此不再赘 述。
本领域普通技术人员可以理解实现上述实施例方法中的全部或部分流 程, 是可以通过计算机程序来指令相关的硬件来完成, 上述的程序可存储于 一计算机可读取存储介质中, 该程序在执行时, 可包括如上述各方法的实施 例的流程。 其中, 上述的存储介质可为磁碟、 光盘、 只读存储记忆体(ROM: Read- Only Memory )或随机存储记忆体 ( RAM: Random Access Memory )等。 施例的说明只是用于帮助理解本发明的技术方案; 同时, 对于本领域的一般 技术人员, 依据本发明的思想, 在具体实施方式及应用范围上均会有改变之 处, 综上所述, 本说明书内容不应理解为对本发明的限制。

Claims

权利要求书
1、 一种文件同步方法, 其特征在于, 包括:
获取第一文件列表快照, 所述第一文件列表快照包含上一次同步结束时本 地文件列表的信息;
将所述第一文件列表快照和当前所述本地文件列表的信息进行比较, 获取 第二文件列表快照, 所述第二文件列表快照包含当前所述本地文件列表的更新 操作;
向服务器发送文件列表快照请求;
接收所述服务器发送的第三文件列表快照, 所述第三文件列表快照包含所 述服务器的文件列表的信息;
根据所述第二文件列表快照和所述第三文件列表快照确定待同步文件的标 识和操作, 并根据所述待同步文件的标识和操作与所述服务器进行文件同步。
2、 如权利要求 1所述的方法, 其特征在于, 所述当前所述本地文件列表的 更新操作包括本地添加、 本地删除和本地爹改。
3、 如权利要求 2所述的方法, 其特征在于, 所述根据所述第二文件列表快 照和所述第三文件列表快照确定待同步文件的标识和操作包括:
根据所述第二文件列表快照和所述第三文件列表快照, 确定所述服务器的 文件列表的更新操作;
根据所述本地文件列表的更新操作和所述服务器的文件列表的更新操作, 确定所述待同步文件的标识和操作。
4、 如权利要求 3所述的方法, 其特征在于, 所述根据所述本地文件列表的 更新操作和所述服务器的文件列表的更新操作, 确定所述待同步文件的标识和 操作包括:
根据所述本地文件列表的更新操作和所述服务器的文件列表的更新操作, 确定操作分类;
根据所述操作分类, 对所述本地文件列表的更新操作和所述服务器的文件 列表的更新操作进行合并, 确定所述待同步文件的标识和操作。
5、 如权利要求 1-4任一所述的方法, 其特征在于, 所述根据所述待同步文件 的标识和操作与所述服务器进行文件同步还包括:
当接收所述服务器发送的所述服务器正在与其他可用于同步的装置进行文 件同步的状态时, 暂停与所述服务器的文件同步操作。
6、 如权利要求 1-5任一所述的方法, 其特征在于, 所述待同步文件的标识和 操作中的操作包括上传、 下载、 重命名或删除。
7、 如权利要求 1-6任一所述的方法, 其特征在于, 还包括:
设置工作模式, 所述工作模式包括单向同步、 双向同步或选择性同步。
8、 一种可用于同步的装置, 其特征在于, 包括:
第一获取单元, 用于获取第一文件列表快照, 所述第一文件列表快照包含 上一次同步结束时本地文件列表的信息;
第二获取单元, 用于将所述第一获取单元获取的第一文件列表快照和当前 所述本地文件列表的信息进行比较, 获取第二文件列表快照, 所述第二文件列 表快照包含当前所述本地文件列表的更新操作;
发送单元, 用于向服务器发送文件列表快照请求;
接收单元, 用于接收所述服务器发送的第三文件列表快照, 所述第三文件 列表快照包含所述服务器的文件列表的信息;
同步单元, 用于根据所述第二获取单元获取的第二文件列表快照和所述接 收单元接收的第三文件列表快照确定待同步文件的标识和操作, 并根据所述待 同步文件的标识和操作与所述服务器进行文件同步。
9、 如权利要求 8所述的装置, 其特征在于, 所述同步单元具体用于根据所 述第二获取单元获取的第二文件列表快照和所述接收单元接收的第三文件列表 快照, 确定所述服务器的文件列表的更新操作; 以及,
用于根据所述本地文件列表的更新操作和所述服务器的文件列表的更新操 作, 确定所述待同步文件的标识和操作。
10、 如权利要求 8-9任一所述的装置, 其特征在于, 所述同步单元还用于当 接收所述服务器发送的所述服务器正在与其他可用于同步的装置进行文件同步 的状态时, 暂停与所述服务器的文件同步操作。
11、 如权利要求 8-10任一所述的装置, 其特征在于, 还包括:
设置单元, 用于设置工作模式, 所述工作模式包括单向同步、 双向同步或 选择性同步。
PCT/CN2012/076773 2011-12-13 2012-06-12 一种文件同步方法和装置 WO2013086842A1 (zh)

Priority Applications (5)

Application Number Priority Date Filing Date Title
ES12856915.9T ES2563297T3 (es) 2011-12-13 2012-06-12 Método y dispositivo para la sincronización de archivos
KR1020137033562A KR20140010187A (ko) 2011-12-13 2012-06-12 파일 동기화 방법 및 장치
EP12856915.9A EP2706719B1 (en) 2011-12-13 2012-06-12 File synchronization method and device
JP2014526366A JP5870193B2 (ja) 2011-12-13 2012-06-12 ファイル同期方法及び装置
US13/622,660 US20130151468A1 (en) 2011-12-13 2012-09-19 File synchronization method and device

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN201110415376.5 2011-12-13
CN201110415376.5A CN102404338B (zh) 2011-12-13 2011-12-13 一种文件同步方法和装置

Related Child Applications (1)

Application Number Title Priority Date Filing Date
US13/622,660 Continuation US20130151468A1 (en) 2011-12-13 2012-09-19 File synchronization method and device

Publications (1)

Publication Number Publication Date
WO2013086842A1 true WO2013086842A1 (zh) 2013-06-20

Family

ID=45886124

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2012/076773 WO2013086842A1 (zh) 2011-12-13 2012-06-12 一种文件同步方法和装置

Country Status (6)

Country Link
EP (1) EP2706719B1 (zh)
JP (1) JP5870193B2 (zh)
KR (1) KR20140010187A (zh)
CN (1) CN102404338B (zh)
ES (1) ES2563297T3 (zh)
WO (1) WO2013086842A1 (zh)

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2016042254A (ja) * 2014-08-15 2016-03-31 富士ゼロックス株式会社 通信端末、通信システム及びプログラム
CN117112508A (zh) * 2023-10-20 2023-11-24 杭州美创科技股份有限公司 基于序号的文件同步方法、装置、计算机设备及存储介质

Families Citing this family (26)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102404338B (zh) * 2011-12-13 2014-08-20 华为技术有限公司 一种文件同步方法和装置
CN107479911B (zh) * 2012-07-27 2021-07-16 华为终端有限公司 下载应用程序的方法、用户设备和应用服务器
CN103237007A (zh) * 2013-03-22 2013-08-07 华为技术有限公司 媒体文件更新方法及装置
CN103220358B (zh) * 2013-04-19 2016-12-28 深圳如果技术有限公司 一种多终端在线文件同步方法、系统、服务器及终端设备
CN103258018B (zh) * 2013-04-27 2016-08-10 北京金和软件股份有限公司 一种精确监控目录文件夹中文件变化的文件同步方法
CN103365688B (zh) * 2013-06-28 2018-08-31 深圳市掌讯通讯设备有限公司 一种安卓智能设备间软件自动安装与同步方法
CN103369037A (zh) * 2013-06-28 2013-10-23 深圳市掌讯通讯设备有限公司 一种安卓智能设备间数据自动同步方法
CN103473341A (zh) * 2013-09-23 2013-12-25 网易(杭州)网络有限公司 一种播放列表生成方法和设备
CN104796442B (zh) * 2014-01-17 2020-08-07 腾讯科技(深圳)有限公司 网页访问信息同步方法、装置及系统
CN104488248B (zh) * 2014-04-15 2017-09-08 华为技术有限公司 一种文件同步方法、服务器及终端
WO2016121083A1 (ja) * 2015-01-30 2016-08-04 株式会社日立製作所 計算機システム、分散オブジェクト共有方法、エッジノード
CN104580533B (zh) * 2015-02-05 2018-06-19 中国农业银行股份有限公司 一种交易文件的下发方法及装置
CN106682040A (zh) * 2015-11-11 2017-05-17 中兴通讯股份有限公司 数据管理方法及装置
CN106101265A (zh) * 2016-07-26 2016-11-09 浪潮软件股份有限公司 一种在网盘和桌面端之间进行文件同步的方法
CN106302672A (zh) * 2016-08-05 2017-01-04 上海斐讯数据通信技术有限公司 网络管理系统及其数据同步方法
CN106375861A (zh) * 2016-10-10 2017-02-01 合网络技术(北京)有限公司 视频播放方法及装置
CN106657274A (zh) * 2016-11-16 2017-05-10 武汉斗鱼网络科技有限公司 对应用文件进行处理的方法及装置
CN107103192A (zh) * 2017-04-21 2017-08-29 上海联影医疗科技有限公司 医学图像处理系统及其数据管理方法
CN107819871B (zh) * 2017-11-22 2020-12-25 北京小米移动软件有限公司 应用状态确定方法及装置
CN108573014B (zh) * 2017-12-19 2021-05-28 北京金山云网络技术有限公司 一种文件同步方法、装置、电子设备及可读存储介质
US10866963B2 (en) 2017-12-28 2020-12-15 Dropbox, Inc. File system authentication
CN108921712A (zh) * 2018-06-13 2018-11-30 泰康保险集团股份有限公司 数据处理方法、装置、介质及电子设备
KR102133925B1 (ko) * 2018-07-30 2020-07-14 네이버 주식회사 데이터 동기화 트래픽을 최소화하기 위한 방법 및 시스템
CN109246245A (zh) * 2018-10-31 2019-01-18 武汉新迪数字工程系统有限公司 实现文件同步的方法、服务器、系统及存储介质
CN112084159B (zh) * 2020-07-28 2023-02-21 重庆攸亮科技股份有限公司 一种基于蓝牙通信的文件同步系统和同步方法
CN117290328B (zh) * 2023-11-22 2024-02-27 苏州元脑智能科技有限公司 存储系统文件并发同步方法、装置、设备及可读存储介质

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US6738799B2 (en) * 1999-05-03 2004-05-18 Symantec Corporation Methods and apparatuses for file synchronization and updating using a signature list
CN101453418A (zh) * 2007-12-05 2009-06-10 高德软件有限公司 客户端与服务器同步的更新方法
US7734826B2 (en) * 2001-03-16 2010-06-08 Novell, Inc. Client-server model for synchronization of files
CN102404338A (zh) * 2011-12-13 2012-04-04 华为技术有限公司 一种文件同步方法和装置

Family Cites Families (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP4142866B2 (ja) * 2001-11-07 2008-09-03 カシオソフト株式会社 データベース同期化装置及びプログラム
US7567991B2 (en) * 2003-06-25 2009-07-28 Emc Corporation Replication of snapshot using a file system copy differential
KR100678921B1 (ko) * 2005-10-18 2007-02-05 삼성전자주식회사 다중 서버 환경에 적합한 디바이스를 클라이언트로 하여동기화를 수행하는 방법 및 장치
US8503984B2 (en) * 2009-12-23 2013-08-06 Amos Winbush, III Mobile communication device user content synchronization with central web-based records and information sharing system

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US6738799B2 (en) * 1999-05-03 2004-05-18 Symantec Corporation Methods and apparatuses for file synchronization and updating using a signature list
US7734826B2 (en) * 2001-03-16 2010-06-08 Novell, Inc. Client-server model for synchronization of files
CN101453418A (zh) * 2007-12-05 2009-06-10 高德软件有限公司 客户端与服务器同步的更新方法
CN102404338A (zh) * 2011-12-13 2012-04-04 华为技术有限公司 一种文件同步方法和装置

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
See also references of EP2706719A4 *

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2016042254A (ja) * 2014-08-15 2016-03-31 富士ゼロックス株式会社 通信端末、通信システム及びプログラム
CN117112508A (zh) * 2023-10-20 2023-11-24 杭州美创科技股份有限公司 基于序号的文件同步方法、装置、计算机设备及存储介质
CN117112508B (zh) * 2023-10-20 2024-02-06 杭州美创科技股份有限公司 基于序号的文件同步方法、装置、计算机设备及存储介质

Also Published As

Publication number Publication date
ES2563297T3 (es) 2016-03-14
JP2014524621A (ja) 2014-09-22
CN102404338B (zh) 2014-08-20
CN102404338A (zh) 2012-04-04
JP5870193B2 (ja) 2016-02-24
EP2706719A1 (en) 2014-03-12
KR20140010187A (ko) 2014-01-23
EP2706719A4 (en) 2014-05-07
EP2706719B1 (en) 2015-12-16

Similar Documents

Publication Publication Date Title
WO2013086842A1 (zh) 一种文件同步方法和装置
US10911518B2 (en) Network folder synchronization
US20130151468A1 (en) File synchronization method and device
JP6725742B2 (ja) ファイルストレージ、オブジェクトストレージ、およびストレージシステム
JP5662405B2 (ja) ユーザ装置をプロビジョニングするシステム及び方法
US7620721B2 (en) Pre-existing content replication
US11126590B2 (en) Data processing method and device
WO2017054543A1 (zh) 一种云盘资源访问方法和装置
US10581858B2 (en) Network attached storage (NAS) apparatus having reversible privacy settings for logical storage area shares, and methods of configuring same
WO2015117426A1 (zh) 文件管理方法及装置
WO2017215646A1 (zh) 数据传输方法和装置
US20150227605A1 (en) Information processing terminal, synchronization control method, and computer-readable recording medium
JP2016212656A (ja) 情報処理装置、端末、情報処理装置と端末を有するシステム、情報処理方法及びプログラム
JP6196389B2 (ja) 分散型ディザスタリカバリファイル同期サーバシステム
JP2010250760A (ja) ファイル格納システム、サーバ装置及びプログラム
CN112256797A (zh) 一种基于MongoDB的公安网与政务网的数据同步系统和方法
TWI571754B (zh) 用來進行檔案同步控制之方法與裝置
JP5535998B2 (ja) データ管理システムおよびデータ管理方法
US20230168974A1 (en) Information processing system, information processing method, and storage medium
KR20020003674A (ko) 데이타 동기화 시스템 및 그 방법
CN114930313A (zh) 用于管理区块链节点的系统和方法
TW201118556A (en) Data backup management platform and method thereof
CN113297158B (zh) 一种云安全产品管理方法、装置、设备及存储介质
CN107395753B (zh) 一种云协作过程冲突检测及通知方法
JP5714087B2 (ja) データ管理システムおよびデータ管理方法

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: 12856915

Country of ref document: EP

Kind code of ref document: A1

WWE Wipo information: entry into national phase

Ref document number: 2012856915

Country of ref document: EP

ENP Entry into the national phase

Ref document number: 20137033562

Country of ref document: KR

Kind code of ref document: A

ENP Entry into the national phase

Ref document number: 2014526366

Country of ref document: JP

Kind code of ref document: A

NENP Non-entry into the national phase

Ref country code: DE