public int PatchMappackageWithKey(string Package, byte[] Key = null)
        {
            string Osz2PatchFilename = s3getToTemp("working/" + Package.Replace(".osz2", ".patch"), true);

            if (Osz2PatchFilename == null)
            {
                return((int)UpdateResponseCode.FileDoesNotExist);
            }

            string Osz2Filename = s3getToTemp("osz2/" + Package);

            if (Osz2Filename == null)
            {
                return((int)UpdateResponseCode.FileDoesNotExist);
            }

            string Osz2FilenameTemp = Osz2Filename + ".temp";

            if (!MapPackage.UpdateFromPatch(Osz2Filename, Osz2PatchFilename, Osz2FilenameTemp))
            {
                File.Delete(Osz2PatchFilename);
                File.Delete(Osz2FilenameTemp);
                return((int)UpdateResponseCode.UnknownError);
            }

            File.Delete(Osz2Filename);
            File.Move(Osz2FilenameTemp, Osz2Filename);

            //check if updated mappackage is valid
            UpdateResponseCode code = DoMapPackageActionSafe((M) => { return(UpdateResponseCode.UpdateSuccessful); }, Osz2Filename, Key, false, false);

            if (code != UpdateResponseCode.UpdateSuccessful)
            {
                return((int)code);
            }

            //copy patched file back to the original
            try
            {
                //when replacing failed it will automaticaly be restored to the previous version
                s3putFile("osz2/" + Package, Osz2Filename);
            }
            catch (Exception e)
            {
                log(e);
                //todo add logger here
                code = UpdateResponseCode.CopyingFailed;
            }
            finally
            {
                File.Delete(Osz2PatchFilename);
            }

            return((int)code);
        }