fix(Export internal data documents provider): Correct S_IFLNK constant and symlink detection mask (#6819)
This commit is contained in:
+6
-3
@@ -31,7 +31,10 @@ public class InternalDataDocumentsProvider extends DocumentsProvider {
|
|||||||
private static final String[] directoryColumns =
|
private static final String[] directoryColumns =
|
||||||
{"document_id", "mime_type", "_display_name", "last_modified", "flags",
|
{"document_id", "mime_type", "_display_name", "last_modified", "flags",
|
||||||
"_size", "full_path", "lstat_info"};
|
"_size", "full_path", "lstat_info"};
|
||||||
private static final int S_IFLNK = 0x8000;
|
@SuppressWarnings("OctalInteger")
|
||||||
|
private static final int S_IFMT = 0170000;
|
||||||
|
@SuppressWarnings("OctalInteger")
|
||||||
|
private static final int S_IFLNK = 0120000;
|
||||||
|
|
||||||
private String packageName;
|
private String packageName;
|
||||||
private File dataDirectory;
|
private File dataDirectory;
|
||||||
@@ -47,7 +50,7 @@ public class InternalDataDocumentsProvider extends DocumentsProvider {
|
|||||||
if (root.isDirectory()) {
|
if (root.isDirectory()) {
|
||||||
try {
|
try {
|
||||||
// Only delete recursively if the directory is not a symlink
|
// Only delete recursively if the directory is not a symlink
|
||||||
if ((Os.lstat(root.getPath()).st_mode & S_IFLNK) != S_IFLNK) {
|
if ((Os.lstat(root.getPath()).st_mode & S_IFMT) != S_IFLNK) {
|
||||||
File[] files = root.listFiles();
|
File[] files = root.listFiles();
|
||||||
if (files != null) {
|
if (files != null) {
|
||||||
for (File file : files) {
|
for (File file : files) {
|
||||||
@@ -324,7 +327,7 @@ public class InternalDataDocumentsProvider extends DocumentsProvider {
|
|||||||
sb.append(";");
|
sb.append(";");
|
||||||
sb.append(lstat.st_gid);
|
sb.append(lstat.st_gid);
|
||||||
// Append symlink target if it is a symlink
|
// Append symlink target if it is a symlink
|
||||||
if ((lstat.st_mode & S_IFLNK) == S_IFLNK) {
|
if ((lstat.st_mode & S_IFMT) == S_IFLNK) {
|
||||||
sb.append(";");
|
sb.append(";");
|
||||||
sb.append(Os.readlink(path));
|
sb.append(Os.readlink(path));
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user