Skip to content

Commit

Permalink
Create DUI3Config.db file and objects table if not exists (#389)
Browse files Browse the repository at this point in the history
  • Loading branch information
oguzhankoral authored Sep 5, 2024
1 parent abe9de1 commit c1b8ec7
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions speckle_connector_3/src/preferences/preferences.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,11 @@ module Preferences

# @param sketchup_model [Sketchup::Model] active model.
def self.read_preferences(sketchup_model)
unless File.exist?(SPECKLE_CONFIG_DB_PATH)
File.new(SPECKLE_CONFIG_DB_PATH, "w")
db = Sqlite3::Database.new(SPECKLE_CONFIG_DB_PATH)
create_objects_table(db)
end
db = Sqlite3::Database.new(SPECKLE_CONFIG_DB_PATH)
user_preferences = validate_user_preferences(db)
model_preferences = validate_model_preferences(sketchup_model)
Expand All @@ -29,6 +34,17 @@ def self.read_preferences(sketchup_model)
)
end

# Creates the 'objects' table in the database if it doesn't already exist.
# @param db [Sqlite3::Database] the SQLite3 database instance.
def self.create_objects_table(db)
db.exec <<-SQL
CREATE TABLE IF NOT EXISTS objects (
hash TEXT PRIMARY KEY,
content TEXT
);
SQL
end

# Whether row data is complete with preference or not.
# It is useful for backward compatibility, when we add new preferences it should be reset when user initialize it.
def self.data_complete?(row_data)
Expand Down

0 comments on commit c1b8ec7

Please sign in to comment.