Skip to content

Commit

Permalink
[Refactor] Make setting UID/GID optional while extracting a tar archive
Browse files Browse the repository at this point in the history
Signed-off-by: Muntashir Al-Islam <muntashirakon@riseup.net>
  • Loading branch information
MuntashirAkon committed Sep 19, 2023
1 parent 788c2fa commit e31888e
Showing 1 changed file with 3 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

package io.github.muntashirakon.AppManager.utils;

import android.system.ErrnoException;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.annotation.StringDef;
Expand Down Expand Up @@ -206,15 +204,15 @@ public static void extract(@NonNull @TarType String type, @NonNull Path[] source
}
}
// Fix permissions
Paths.setPermissions(file, entry.getMode(), entry.getUserId(), entry.getGroupId());
TarArchiveEntry finalEntry = entry;
ExUtils.exceptionAsIgnored(() -> Paths.setPermissions(file, finalEntry.getMode(),
finalEntry.getUserId(), finalEntry.getGroupId()));
// Restore timestamp
long modificationTime = entry.getModTime().getTime();
if (modificationTime > 0) { // Backward-compatibility
file.setLastModified(entry.getModTime().getTime());
}
}
} catch (ErrnoException e) {
throw new IOException(e);
} finally {
is.close();
}
Expand Down

0 comments on commit e31888e

Please sign in to comment.