[Pkg-owncloud-commits] [owncloud-client] 37/219: t4.pl: add a test to test that ignored file are not deleted
Sandro Knauß
hefee-guest at moszumanska.debian.org
Sat Oct 11 14:43:06 UTC 2014
This is an automated email from the git hooks/post-receive script.
hefee-guest pushed a commit to branch master
in repository owncloud-client.
commit a73fbccf8cd77dadfec8100cf4f9ce663882a307
Author: Olivier Goffart <ogoffart at woboq.com>
Date: Thu Aug 28 19:33:52 2014 +0200
t4.pl: add a test to test that ignored file are not deleted
---
csync/src/csync_update.c | 9 +++++----
csync/tests/ownCloud/exclude.cfg | 4 +++-
csync/tests/ownCloud/ownCloud/Test.pm | 2 +-
csync/tests/ownCloud/t4.pl | 18 +++++++++++++++++-
src/owncloudcmd/owncloudcmd.cpp | 8 ++++++++
5 files changed, 34 insertions(+), 7 deletions(-)
diff --git a/csync/src/csync_update.c b/csync/src/csync_update.c
index 8805202..761b371 100644
--- a/csync/src/csync_update.c
+++ b/csync/src/csync_update.c
@@ -664,10 +664,6 @@ int csync_ftw(CSYNC *ctx, const char *uri, csync_walker_fn fn,
/* If a directory has modified files, put the flag on the parent directory as well */
previous_fs->child_modified = ctx->current_fs->child_modified;
}
- if (ctx->current_fs && previous_fs && ctx->current_fs->has_ignored_files) {
- /* If a directory has ignored files, put the flag on the parent directory as well */
- previous_fs->has_ignored_files = ctx->current_fs->has_ignored_files;
- }
/* Only for the local replica we have to destroy stat(), for the remote one it is a pointer to dirent */
if (ctx->replica == LOCAL_REPLICA) {
@@ -696,6 +692,11 @@ int csync_ftw(CSYNC *ctx, const char *uri, csync_walker_fn fn,
ctx->current_fs->instruction = CSYNC_INSTRUCTION_NONE;
ctx->current_fs->should_update_etag = true;
}
+
+ if (ctx->current_fs && previous_fs && ctx->current_fs->has_ignored_files) {
+ /* If a directory has ignored files, put the flag on the parent directory as well */
+ previous_fs->has_ignored_files = ctx->current_fs->has_ignored_files;
+ }
}
if (flag == CSYNC_FTW_FLAG_DIR && ctx->current_fs
diff --git a/csync/tests/ownCloud/exclude.cfg b/csync/tests/ownCloud/exclude.cfg
index 8e857f5..034b808 100644
--- a/csync/tests/ownCloud/exclude.cfg
+++ b/csync/tests/ownCloud/exclude.cfg
@@ -1 +1,3 @@
-*_conflict-*
+*.part
+]*.directory
+
diff --git a/csync/tests/ownCloud/ownCloud/Test.pm b/csync/tests/ownCloud/ownCloud/Test.pm
index 74e20be..f93d3c3 100644
--- a/csync/tests/ownCloud/ownCloud/Test.pm
+++ b/csync/tests/ownCloud/ownCloud/Test.pm
@@ -305,7 +305,7 @@ sub csync( ;$ )
print "CSync URL: $url\n";
- my $args = "--trust"; # Trust crappy SSL certificates
+ my $args = "--trust --exclude exclude.cfg"; # Trust crappy SSL certificates
my $cmd = "LD_LIBRARY_PATH=$ld_libpath $csync $args $localDir $url";
print "Starting: $cmd\n";
diff --git a/csync/tests/ownCloud/t4.pl b/csync/tests/ownCloud/t4.pl
index f35c0e9..aa2514d 100755
--- a/csync/tests/ownCloud/t4.pl
+++ b/csync/tests/ownCloud/t4.pl
@@ -38,6 +38,10 @@ printInfo( "Copy some files to the remote location" );
mkdir( localDir() . 'test_stat' );
system( "echo foobar > " . localDir() . 'test_stat/file.txt' );
+mkdir( localDir() . 'test_ignored' );
+mkdir( localDir() . 'test_ignored/sub' );
+system( "echo foobarfoo > " . localDir() . 'test_ignored/sub/file.txt' );
+
# call csync, sync local t1 to remote t1
csync();
@@ -91,15 +95,25 @@ my $realMD5 = md5OfFile( '/tmp/kernelcrash.txt' );
print "MD5 compare $localMD5 <-> $realMD5\n";
assert( $localMD5 eq $realMD5 );
-
printInfo("Added a file that is on the ignore list");
# (*.directory is in the ignored list that needs cleanup)
# (it is names with _conflict) because i want the conflicft detection of assertLocalAndRemoteDir to work
system( "echo dir >> " . localDir() . 'test_stat/file_conflict.directory' );
+# this one should retain the directory
+system( "echo foobarfoo > " . localDir() . 'test_ignored/sub/ignored_conflict.part' );
csync();
# The file_conflict.directory is seen as a conflict
assertLocalAndRemoteDir( '', 1 );
# TODO: check that the file_conflict.directory is indeed NOT on the server
+# TODO: check that test_ignored/sub/ignored_conflict.part is NOT on the server
+assert(-e localDir() . 'test_ignored/sub/ignored_conflict.part');
+
+printInfo("Remove a directory containing an ignored file that should not be removed\n");
+remoteCleanup('test_ignored');
+csync();
+assert(-e localDir() . 'test_ignored/sub/ignored_conflict.part');
+#remove the file so next sync allow the directory to be removed
+system( "rm " . localDir() . 'test_ignored/sub/ignored_conflict.part' );
printInfo("Remove a directory containing a local file\n");
remoteCleanup('test_stat');
@@ -150,6 +164,8 @@ printInfo("Now remove the symlink\n");
system( "rm -f " . localDir() . 'anotherdir' );
csync();
assertLocalAndRemoteDir( '', 0 );
+assert(! -e localDir(). 'anotherdir' );
+
cleanup();
diff --git a/src/owncloudcmd/owncloudcmd.cpp b/src/owncloudcmd/owncloudcmd.cpp
index 23c6602..1f5e80e 100644
--- a/src/owncloudcmd/owncloudcmd.cpp
+++ b/src/owncloudcmd/owncloudcmd.cpp
@@ -40,6 +40,7 @@ struct CmdOptions {
QString proxy;
bool silent;
bool trustSSL;
+ QString exclude;
};
// we can't use csync_set_userdata because the SyncEngine sets it already.
@@ -76,6 +77,7 @@ void help()
std::cout << " --httpproxy = proxy: Specify a http proxy to use." << std::endl;
std::cout << " Proxy is http://server:port" << std::endl;
std::cout << " --trust Trust the SSL certification." << std::endl;
+ std::cout << " --exclude [file] exclude list file" << std::endl;
std::cout << "" << std::endl;
exit(1);
@@ -120,6 +122,8 @@ void parseOptions( const QStringList& app_args, CmdOptions *options )
options->silent = true;
} else if( option == "--trust") {
options->trustSSL = true;
+ } else if( option == "--exclude" && !it.peekNext().startsWith("-") ) {
+ options->exclude = it.next();
} else {
help();
}
@@ -214,6 +218,10 @@ int main(int argc, char **argv) {
clientProxy.setCSyncProxy(QUrl(url), _csync_ctx);
}
+ if (!options.exclude.isEmpty()) {
+ csync_add_exclude_list(_csync_ctx, options.exclude.toLocal8Bit());
+ }
+
OwncloudCmd owncloudCmd;
SyncJournalDb db(options.source_dir);
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-owncloud/owncloud-client.git
More information about the Pkg-owncloud-commits
mailing list