1414import android .os .Looper ;
1515import android .util .Log ;
1616
17+ import org .appdevforall .k2go .boxidentity .data .CopyExcludeFiles ;
18+ import org .appdevforall .k2go .boxidentity .domain .CopyExcludes ;
1719import org .appdevforall .k2go .sync .domain .RsyncConfig ;
1820import org .appdevforall .k2go .sync .domain .RsyncOutcome ;
1921import org .appdevforall .k2go .sync .domain .RsyncProgress ;
@@ -77,11 +79,16 @@ public boolean startServer(Context context, ShareConfig config, String pass, Str
7779 secretStore = new SecretStore (cacheDir );
7880 File secretsFile = secretStore .writeServerSecrets (config .user , pass );
7981
82+ // K2GO-549: the share is the box root. A copy never carries its records. An exception
83+ // here fails the start: no share without the list.
84+ File excludes = CopyExcludeFiles .rsync (context );
85+
8086 // PHASE 1 FIX: 'max connections = 3' protects the I/O bottleneck.
8187 // Config/argv assembly lives in the pure RsyncConfig domain (S14 step 1).
8288 String configContent = RsyncConfig .buildDaemonConf (
8389 pidFile .getAbsolutePath (), lockFile .getAbsolutePath (), config .rsyncPort ,
84- config .moduleName , dirToShare , config .user , secretsFile .getAbsolutePath ());
90+ config .moduleName , dirToShare , config .user , secretsFile .getAbsolutePath (),
91+ excludes .getAbsolutePath ());
8592
8693 writeTextToFile (configFile , configContent );
8794
@@ -128,8 +135,10 @@ public void startClient(Context context, ShareConfig config, String hostIp, int
128135
129136 String remoteUrl = RsyncConfig .buildRemoteUrl (user , hostIp , port , config .moduleName );
130137
131- ProcessBuilder pb = new ProcessBuilder (RsyncConfig .clientArgs (
132- rsyncBin .getAbsolutePath (), passFile .getAbsolutePath (), remoteUrl , destinationDir ));
138+ // K2GO-549: also filter here, for a sender whose APK has no exclude list.
139+ ProcessBuilder pb = new ProcessBuilder (RsyncConfig .withExcludes (RsyncConfig .clientArgs (
140+ rsyncBin .getAbsolutePath (), passFile .getAbsolutePath (), remoteUrl , destinationDir ),
141+ CopyExcludeFiles .rsync (context ).getAbsolutePath (), CopyExcludes .rsyncProtectRules ()));
133142
134143 pb .redirectErrorStream (true );
135144 rsyncProcess = pb .start ();
@@ -232,7 +241,8 @@ else if (line.contains("@ERROR:") || line.startsWith("rsync:")
232241 + (RsyncOutcome .isSuccess (exitCode ) && exitCode != 0
233242 ? " (non-zero treated as complete — see any [Rsync Output Error] lines above)" : "" ));
234243 if (isCancelled ) {
235- mainHandler .post (() -> listener .onError (context .getString (R .string .rsync_error_cancelled )));
244+ // The cancel path already reset the screen (CloneFragment.onReceiveCancel).
245+ Log .i (TAG , "Rsync client stopped by the user" );
236246 } else {
237247 switch (RsyncOutcome .classifyTransfer (exitCode )) {
238248 case COMPLETE :
@@ -251,6 +261,12 @@ else if (line.contains("@ERROR:") || line.startsWith("rsync:")
251261 }
252262
253263 } catch (Exception e ) {
264+ // A user Cancel closes the stream under the reader. The cancel path already reset
265+ // the screen (CloneFragment.onReceiveCancel), so it is not an error.
266+ if (isCancelled ) {
267+ Log .i (TAG , "Rsync client stopped by the user" );
268+ return ;
269+ }
254270 Log .e (TAG , "Rsync Client Exception" , e );
255271 mainHandler .post (() -> listener .onError (context .getString (R .string .rsync_error_fatal , e .getMessage ())));
256272 }
@@ -284,8 +300,9 @@ public void calculateTransferPlan(Context context, ShareConfig config, String ho
284300
285301 String remoteUrl = RsyncConfig .buildRemoteUrl (user , hostIp , port , config .moduleName );
286302
287- ProcessBuilder pb = new ProcessBuilder (RsyncConfig .dryRunArgs (
288- rsyncBin .getAbsolutePath (), passFile .getAbsolutePath (), remoteUrl , destinationDir ));
303+ ProcessBuilder pb = new ProcessBuilder (RsyncConfig .withExcludes (RsyncConfig .dryRunArgs (
304+ rsyncBin .getAbsolutePath (), passFile .getAbsolutePath (), remoteUrl , destinationDir ),
305+ CopyExcludeFiles .rsync (context ).getAbsolutePath (), CopyExcludes .rsyncProtectRules ()));
289306
290307 pb .redirectErrorStream (true );
291308 rsyncProcess = pb .start ();
0 commit comments