Skip to content

Commit

Permalink
NXDRIVE-1118: Fix obsolete synced files deletion
Browse files Browse the repository at this point in the history
It happens when using the same local sync
folder with an account, delete it and use
another account.  Old files have to be
removed locally without ny error.

Also:
* Do not enable Sonar on particular test
  • Loading branch information
BoboTiG authored Feb 20, 2018
1 parent 7a4b52e commit 3fc31ba
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 45 deletions.
16 changes: 11 additions & 5 deletions nuxeo-drive-client/nxdrive/engine/processor.py
Original file line number Diff line number Diff line change
Expand Up @@ -559,7 +559,7 @@ def _synchronize_locally_created(self, doc_pair, local_client,
if 'default#' in remote_ref:
# Document appears to be deleted server side.
self._synchronize_remotely_deleted(
doc_pair, local_client, remote_client)
doc_pair, local_client, remote_client, force=True)
return

try:
Expand Down Expand Up @@ -1072,7 +1072,13 @@ def _create_remotely(self, local, remote, doc_pair, parent_pair, name):
finally:
self._lock_readonly(local, local_parent_path)

def _synchronize_remotely_deleted(self, doc_pair, local_client, remote_client):
def _synchronize_remotely_deleted(
self,
doc_pair,
local_client,
remote_client,
force=False
):
try:
if doc_pair.local_state != 'deleted':
log.debug('Deleting locally %r', local_client.abspath(doc_pair.local_path))
Expand All @@ -1083,10 +1089,10 @@ def _synchronize_remotely_deleted(self, doc_pair, local_client, remote_client):
file_out = self._get_temporary_file(local_client.abspath(doc_pair.local_path))
if os.path.exists(file_out):
os.remove(file_out)
if self._engine.use_trash():
local_client.delete(doc_pair.local_path)
else:
if force or not self._engine.use_trash():
local_client.delete_final(doc_pair.local_path)
else:
local_client.delete(doc_pair.local_path)
self._dao.remove_state(doc_pair)
self._search_for_dedup(doc_pair)
finally:
Expand Down
39 changes: 0 additions & 39 deletions nuxeo-drive-client/tests/test_synchronization.py
Original file line number Diff line number Diff line change
Expand Up @@ -475,45 +475,6 @@ def test_conflict_detection(self):
self.assertEqual(remote_children[0].filename, 'Some File.doc')
self.assertEqual(remote_1.get_content('/Some File.doc'), 'Remote new content.')

def test_synchronize_deep_folders(self):
# Increase Automation execution timeout for NuxeoDrive.GetChangeSummary
# because of the recursive parent FileSystemItem adaptation
self.engine_1.timeout = 90

# Create a file deep down in the hierarchy
remote = self.remote_document_client_1

folder_name = '0123456789'
folder_depth = 40
folder = '/'
for _ in range(folder_depth):
folder = remote.make_folder(folder, folder_name)

remote.make_file(folder, "File.odt", content="Fake non-zero content.")

# Wait for ES indexing
self.wait()
self.engine_1.start()
self.wait_sync(timeout=90)

local = self.local_client_1
expected_folder_path = ('/' + folder_name) * folder_depth

expected_file_path = expected_folder_path + '/File.odt'
self.assertTrue(local.exists(expected_folder_path))
self.assertTrue(local.exists(expected_file_path))
self.assertEqual(local.get_content(expected_file_path),
"Fake non-zero content.")

# Delete the nested folder structure on the remote server
# and synchronize again
remote.delete('/' + folder_name)

self.wait_sync(wait_for_async=True, timeout=90)

self.assertFalse(local.exists(expected_folder_path))
self.assertFalse(local.exists(expected_file_path))

def test_create_content_in_readonly_area(self):
self.engine_1.start()
self.wait_sync(wait_for_async=True)
Expand Down
2 changes: 1 addition & 1 deletion tools/jenkins/tests.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ timeout(240) {
timestamps {
parallel builders

if (env.ENABLE_SONAR && currentBuild.result != 'UNSTABLE') {
if (env.ENABLE_SONAR && currentBuild.result != 'UNSTABLE' && env.SPECIFIC_TEST == '') {
node('SLAVE') {
stage('SonarQube Analysis') {
try {
Expand Down

0 comments on commit 3fc31ba

Please sign in to comment.