Bug 696474

Summary: python client should only delete files from server which no longer exist on client
Product: [Retired] Zanata Reporter: Sean Flanigan <sflaniga>
Component: Component-PythonClientAssignee: James Ni <jni>
Status: CLOSED CURRENTRELEASE QA Contact: David Mason <damason>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: unspecifiedCC: damason, zanata-bugs
Target Milestone: ---   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: 1.3.3 Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2012-03-07 01:33:56 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On:    
Bug Blocks: 786670    

Description Sean Flanigan 2011-04-14 06:07:19 UTC
Description of problem:
When pushing files to Zanata, the python client first removes *all* existing documents from the server.  It should only delete the files which need to be removed, ie files which don't exist on the client.

Version-Release number of selected component (if applicable):
0:1.2.2-1.fc13

Comment 1 James Ni 2011-04-26 09:14:06 UTC
I make changes for publican push, the the python client only delete the files which don't exist on the client.

If user push a single file to server with 'publican push', i still require source folder and then python client could still check whether existing server files still exist on the client.

For software projects, it could be tricky, since most software project only have one pot file, this kind of compare between server and client is meaningless. We need to find a better way for that.

Please check commit 1bafce3 of devel branch of zanataclient.

Comment 2 Sean Flanigan 2011-05-03 01:24:13 UTC
So for doc projects, if the user pushes a single file, do you delete any other files?

For software projects, can't you request a list of files from the server, and delete all of them except the one which you are about to push?  (Most of the time, there will only be one file, and it will have the same name, so you won't have to delete anything.)

Comment 3 James Ni 2011-05-03 02:14:44 UTC
No, if user push a single file for doc projects, i will not delete any other files, I still request a list of files from the server, and check if all of them are still on the client side, if not, i will delete it. 

So basically, for doc projects, I will do this check before the publican push, whatever the content that user want to push: a single file or a folder of source file.

Comment 4 James Ni 2011-05-04 01:30:56 UTC
I modify the deleting files from server for software projects based on your suggestion, the changes are in commit 524508e of devel branch of zanataclient on github.

Comment 5 Ding-Yi Chen 2011-10-19 04:20:34 UTC
On version 1.3.1

Test case 1: (Passed)
For project AboutFedora, version f11
Assume project and version are created, and current work directory is in AboutFedora, and zanata.xml and zanata.ini are configured properly.
1. zanata push --project-type=podir
2. rm -f pot/Author_Group.pot
3. zanata push --project-type=podir

Results:
As expected, Author_Group is removed from zanata server

Test case 2: (Failed)
Continue from test case 1:
1. zanata push --project-type=podir About_Fedora.pot

Expected:
About_Fedora.pot is update, other documents are not touched

Actual:
zanata-python-client showed:
Delete the Article_Info

Delete the Revision_History

Comment 6 James Ni 2011-10-19 09:59:29 UTC
Hi Ding, 

Thanks for your testing, i just add a process for deleting files from server for project type is podir, the python client will request a list of files from the server, and check if all of them are still in the source folder, if not, the python client will delete it.

But please be careful the source folder, the python client will try to find po files under current first, if can not find anyone, then it will try pot folder. so if the python client find any pot file under current path, it will assume that source folder is *current path*.

And for deleting method, python client will get file list from server, and check if all of them are still in the *source folder*, if not, the python client will delete it from server.

So when you using 'zanata push --project-type=podir About_Fedora.pot', please make sure that About_Fedora.pot is in ./pot, and there is no pot file under current path, otherwise, if you push About_Fedora.pot from current path, the python client will still delete the file from server, since these file can not find under current path, but actually these files are in pot folder.

The commit 137c46e include the changes, please help me to verify it and hope you understand my meanings, if you find this change didn't meat your requirement, please let me know.

Comment 7 James Ni 2011-10-21 02:13:50 UTC
Ok, according to Sean's suggestion, if user pushing single file, python client will not check the files on server and delete them. please check commit 1ac731f for the changes.

Comment 8 David Mason 2012-02-22 01:43:29 UTC
Verified in current head (commit 7cff8ef6b60bea8981a0f62f35ac3d44f9f9390c).

Deletes missing files from server when pushing all files.
Does not delete missing files from server when pushing a single file.

See: https://github.com/zanata/zanata-python-client/commit/7cff8ef6b60bea8981a0f62f35ac3d44f9f9390c

Comment 9 Sean Flanigan 2012-03-07 00:15:55 UTC
James, please fill in the Fixed in Version (not a git commit ID; the next version of zanata-python-client will do).  Then when the next release goes out, please mark it as CLOSED.

Comment 10 James Ni 2012-03-07 01:33:56 UTC
It is already fixed in 1.3.3 of zanata-python-client, so close it as CURRENTRELEASE