mirror of
https://github.com/tsolomko/SWCompression.git
synced 2026-06-23 14:56:41 +00:00
Throw error on non-number required tar entry fields
Previously, when encountering a required field from tar entry header which cannot be converted to Int SWCompression was silently skipping this problem and proceeding further. Now it throws `fieldIsNotNumber`, consistently with other fields.
This commit is contained in:
+13
-19
@@ -188,31 +188,25 @@ public class TarEntry: ContainerEntry {
|
||||
index += 100
|
||||
|
||||
// File mode
|
||||
if let octalPosixPermissions = Int(try data.nullSpaceEndedAsciiString(index, 8)) {
|
||||
let posixPermissions = octalToDecimal(octalPosixPermissions)
|
||||
attributesDict[FileAttributeKey.posixPermissions] = posixPermissions
|
||||
mode = posixPermissions
|
||||
} else {
|
||||
mode = nil
|
||||
}
|
||||
guard let octalPosixPermissions = Int(try data.nullSpaceEndedAsciiString(index, 8))
|
||||
else { throw TarError.fieldIsNotNumber }
|
||||
let posixPermissions = octalToDecimal(octalPosixPermissions)
|
||||
attributesDict[FileAttributeKey.posixPermissions] = posixPermissions
|
||||
mode = posixPermissions
|
||||
index += 8
|
||||
|
||||
// Owner's user ID
|
||||
if let ownerAccountID = Int(try data.nullSpaceEndedAsciiString(index, 8)) {
|
||||
attributesDict[FileAttributeKey.ownerAccountID] = ownerAccountID
|
||||
ownerID = ownerAccountID
|
||||
} else {
|
||||
ownerID = nil
|
||||
}
|
||||
guard let ownerAccountID = Int(try data.nullSpaceEndedAsciiString(index, 8))
|
||||
else { throw TarError.fieldIsNotNumber }
|
||||
attributesDict[FileAttributeKey.ownerAccountID] = ownerAccountID
|
||||
ownerID = ownerAccountID
|
||||
index += 8
|
||||
|
||||
// Group's user ID
|
||||
if let groupAccountID = Int(try data.nullSpaceEndedAsciiString(index, 8)) {
|
||||
attributesDict[FileAttributeKey.groupOwnerAccountID] = groupAccountID
|
||||
groupID = groupAccountID
|
||||
} else {
|
||||
groupID = nil
|
||||
}
|
||||
guard let groupAccountID = Int(try data.nullSpaceEndedAsciiString(index, 8))
|
||||
else { throw TarError.fieldIsNotNumber }
|
||||
attributesDict[FileAttributeKey.groupOwnerAccountID] = groupAccountID
|
||||
groupID = groupAccountID
|
||||
index += 8
|
||||
|
||||
// File size
|
||||
|
||||
Reference in New Issue
Block a user