Skip to content

Commit

Permalink
Moved Functionality in Storage
Browse files Browse the repository at this point in the history
  • Loading branch information
Ali Rıza Kat committed Aug 14, 2024
1 parent 8cb8b57 commit 1836f45
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 26 deletions.
16 changes: 1 addition & 15 deletions lib/countly-bulk.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,21 +104,7 @@ function CountlyBulk(conf) {
conf.maxStackTraceLinesPerThread = conf.max_stack_trace_lines_per_thread || maxStackTraceLinesPerThread;
conf.maxStackTraceLineLength = conf.max_stack_trace_line_length || maxStackTraceLineLength;

CountlyStorage.setBulkDataPath(conf.storage_path);

var mainDir = path.resolve(__dirname, CountlyStorage.getStoragePath());
if (conf.persist_queue) {
try {
if (!fs.existsSync(mainDir)) {
fs.mkdirSync(mainDir);
}
}
catch (ex) {
// problem creating directory
// eslint-disable-next-line no-console
cc.log(cc.logLevelEnums.ERROR, "CountlyBulk, Failed white creating the '/data' directory. Error: ", ex.stack);
}
}
CountlyStorage.setBulkDataPath(conf.storage_path, conf.persist_queue);

this.conf = conf;
/**
Expand Down
26 changes: 25 additions & 1 deletion lib/countly-storage.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,34 @@ var defaultBulkPath = "../bulk_data/"; // Default path

var setStoragePath = function(userPath) {
storagePath = userPath || defaultPath;

var dir = path.resolve(__dirname, getStoragePath());
try {
if (!fs.existsSync(dir)) {
fs.mkdirSync(dir, { recursive: true });
}
}
catch (ex) {
// problem creating data dir
cc.log(cc.logLevelEnums.ERROR, `setStoragePath, Failed to create the '/data' folder: ${ex}`);
}
};

var setBulkDataPath = function(userPath) {
var setBulkDataPath = function(userPath, persistQueue) {
storagePath = userPath || defaultBulkPath;
var mainDir = path.resolve(__dirname, getStoragePath());
if (persistQueue) {
try {
if (!fs.existsSync(mainDir)) {
fs.mkdirSync(mainDir);
}
}
catch (ex) {
// problem creating directory
// eslint-disable-next-line no-console
cc.log(cc.logLevelEnums.ERROR, "setBulkDataPath, Failed white creating the '/data' directory. Error: ", ex.stack);
}
}
};

var getStoragePath = function() {
Expand Down
10 changes: 0 additions & 10 deletions lib/countly.js
Original file line number Diff line number Diff line change
Expand Up @@ -173,16 +173,6 @@ Countly.Bulk = Bulk;
cc.debug = conf.debug;
CountlyStorage.setStoragePath(conf.storage_path);

var dir = path.resolve(__dirname, CountlyStorage.getStoragePath());
try {
if (!fs.existsSync(dir)) {
fs.mkdirSync(dir, { recursive: true });
}
}
catch (ex) {
// problem creating data dir
cc.log(cc.logLevelEnums.ERROR, `init, Failed to create the '/data' folder: ${ex}`);
}
// clear stored device ID if flag is set
if (conf.clear_stored_device_id) {
cc.log(cc.logLevelEnums.WARNING, "init, clear_stored_device_id is true, erasing the stored ID.");
Expand Down

0 comments on commit 1836f45

Please sign in to comment.