| 1895 | } |
| 1896 | |
| 1897 | void Array::upgrade_version( |
| 1898 | ContextResources& resources, |
| 1899 | const URI& array_uri, |
| 1900 | const Config& override_config) { |
| 1901 | // Check if array exists |
| 1902 | if (!is_array(resources, array_uri)) { |
| 1903 | throw ArrayException( |
| 1904 | "Cannot upgrade array; Array '" + array_uri.to_string() + |
| 1905 | "' does not exist"); |
| 1906 | } |
| 1907 | |
| 1908 | // Load URIs from the array directory |
| 1909 | tiledb::sm::ArrayDirectory array_dir{ |
| 1910 | resources, |
| 1911 | array_uri, |
| 1912 | 0, |
| 1913 | UINT64_MAX, |
| 1914 | tiledb::sm::ArrayDirectoryMode::SCHEMA_ONLY}; |
| 1915 | |
| 1916 | // Get encryption key from config |
| 1917 | bool found = false; |
| 1918 | std::string encryption_key_from_cfg = |
| 1919 | override_config.get("sm.encryption_key", &found); |
| 1920 | passert(found, "No value found for config {}", "sm.encryption_key"); |
| 1921 | std::string encryption_type_from_cfg = |
| 1922 | override_config.get("sm.encryption_type", &found); |
| 1923 | passert(found, "No value found for config {}", "sm.encryption_type"); |
| 1924 | auto [st1, etc] = encryption_type_enum(encryption_type_from_cfg); |
| 1925 | throw_if_not_ok(st1); |
| 1926 | EncryptionType encryption_type_cfg = etc.value(); |
| 1927 | |
| 1928 | EncryptionKey encryption_key_cfg; |
| 1929 | if (encryption_key_from_cfg.empty()) { |
| 1930 | throw_if_not_ok( |
| 1931 | encryption_key_cfg.set_key(encryption_type_cfg, nullptr, 0)); |
| 1932 | } else { |
| 1933 | throw_if_not_ok(encryption_key_cfg.set_key( |
| 1934 | encryption_type_cfg, |
| 1935 | (const void*)encryption_key_from_cfg.c_str(), |
| 1936 | static_cast<uint32_t>(encryption_key_from_cfg.size()))); |
| 1937 | } |
| 1938 | |
| 1939 | auto&& array_schema = array_dir.load_array_schema_latest( |
| 1940 | encryption_key_cfg, resources.ephemeral_memory_tracker()); |
| 1941 | |
| 1942 | if (array_schema->version() < constants::format_version) { |
| 1943 | array_schema->generate_uri(); |
| 1944 | array_schema->set_version(constants::format_version); |
| 1945 | |
| 1946 | // Create array schema directory if necessary |
| 1947 | URI array_schema_dir_uri = |
| 1948 | array_uri.join_path(constants::array_schema_dir_name); |
| 1949 | resources.vfs().create_dir(array_schema_dir_uri); |
| 1950 | |
| 1951 | // Store array schema |
| 1952 | store_array_schema(resources, array_schema, encryption_key_cfg); |
| 1953 | |
| 1954 | // Create commit directory if necessary |
nothing calls this directly
no test coverage detected