]> wimlib.net Git - wimlib/commitdiff
win32_set_special_attributes(): Skip compression IOCTL on encrypted files
authorEric Biggers <ebiggers3@gmail.com>
Sat, 27 Apr 2013 04:23:11 +0000 (23:23 -0500)
committerEric Biggers <ebiggers3@gmail.com>
Sat, 27 Apr 2013 04:23:11 +0000 (23:23 -0500)
src/win32.c

index e9bdeeb87ffd46a1278512a31240a3c32979bab3..a591dd6012f0b7cbd077a0a3a395c60f7f9c02db 100644 (file)
@@ -1663,24 +1663,26 @@ win32_set_special_attributes(HANDLE hFile, const struct wim_inode *inode,
 {
        int ret;
 
-       if (vol_flags & FILE_FILE_COMPRESSION) {
-
-               USHORT format;
-               if (inode->i_attributes & FILE_ATTRIBUTE_COMPRESSED) {
-                       format = COMPRESSION_FORMAT_DEFAULT;
-                       DEBUG("Setting compression flag on \"%ls\"", path);
+       /* Encrypted files cannot be [de]compressed. */
+       if (!(inode->i_attributes & FILE_ATTRIBUTE_ENCRYPTED)) {
+               if (vol_flags & FILE_FILE_COMPRESSION) {
+                       USHORT format;
+                       if (inode->i_attributes & FILE_ATTRIBUTE_COMPRESSED) {
+                               format = COMPRESSION_FORMAT_DEFAULT;
+                               DEBUG("Setting compression flag on \"%ls\"", path);
+                       } else {
+                               format = COMPRESSION_FORMAT_NONE;
+                               DEBUG("Clearing compression flag on \"%ls\"", path);
+                       }
+                       ret = win32_set_compression_state(hFile, format, path);
+                       if (ret)
+                               return ret;
                } else {
-                       format = COMPRESSION_FORMAT_NONE;
-                       DEBUG("Clearing compression flag on \"%ls\"", path);
-               }
-               ret = win32_set_compression_state(hFile, format, path);
-               if (ret)
-                       return ret;
-       } else {
-               if (inode->i_attributes & FILE_ATTRIBUTE_COMPRESSED) {
-                       DEBUG("Cannot set compression attribute on \"%ls\": "
-                             "volume does not support transparent compression",
-                             path);
+                       if (inode->i_attributes & FILE_ATTRIBUTE_COMPRESSED) {
+                               DEBUG("Cannot set compression attribute on \"%ls\": "
+                                     "volume does not support transparent compression",
+                                     path);
+                       }
                }
        }