Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 85192a1b authored by Christopher Tate's avatar Christopher Tate
Browse files

Fix symlink handling during backup

Don't canonicalize and *then* check for symlinks.  It sort of
misses the point....

Bug 22856947

Change-Id: I1c0ffa0dfeba13ca714f43eb7fd9963a0dfbcca3
parent d75247cf
Loading
Loading
Loading
Loading
+9 −5
Original line number Diff line number Diff line
@@ -533,6 +533,14 @@ public abstract class BackupAgent extends ContextWrapper {
                File file = scanQueue.remove(0);
                String filePath;
                try {
                    // Ignore symlinks outright
                    StructStat stat = Os.lstat(file.getPath());
                    if (OsConstants.S_ISLNK(stat.st_mode)) {
                        if (DEBUG) Log.i(TAG, "Symlink (skipping)!: " + file);
                        continue;
                    }

                    // For all other verification, look at the canonicalized path
                    filePath = file.getCanonicalPath();

                    // prune this subtree?
@@ -544,11 +552,7 @@ public abstract class BackupAgent extends ContextWrapper {
                    }

                    // If it's a directory, enqueue its contents for scanning.
                    StructStat stat = Os.lstat(filePath);
                    if (OsConstants.S_ISLNK(stat.st_mode)) {
                        if (DEBUG) Log.i(TAG, "Symlink (skipping)!: " + file);
                        continue;
                    } else if (OsConstants.S_ISDIR(stat.st_mode)) {
                    if (OsConstants.S_ISDIR(stat.st_mode)) {
                        File[] contents = file.listFiles();
                        if (contents != null) {
                            for (File entry : contents) {