Skip to content

Commit

Permalink
Update some file system requirements
Browse files Browse the repository at this point in the history
  • Loading branch information
dmitrydwhite committed Aug 27, 2021
1 parent 6e40cba commit 2d223af
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 1 deletion.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
node_modules
faker_satellite/file_lib/**.*
faker_satellite/for_downlink/**.*
run/downlinked_files/for_downlink/**.*
run/downlinked_files/**/*.*
8 changes: 8 additions & 0 deletions faker_satellite/launch.js
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,10 @@ const uplink_file_chunk = ({ id, chunk }) => {
if (fileReceivers[id]) {
receiveStream = fileReceivers[id];
} else {
if (!fs.existsSync(path.join(__dirname, 'file_lib'))) {
fs.mkdirSync(path.join(__dirname, 'file_lib'));
}

receiveStream = fs.createWriteStream(path.join(__dirname, 'file_lib', `file_${id}`));
fileReceivers[id] = receiveStream;
}
Expand Down Expand Up @@ -304,5 +308,9 @@ process.on('message', obj => {
}
});

if (!fs.existsSync(path.join(__dirname, "for_downlink"))) {
fs.mkdirSync(path.join(__dirname, 'for_downlink'));
}

retrieveImageFile();
process.send(commandDefinitions);
5 changes: 5 additions & 0 deletions run/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -265,9 +265,14 @@ const downlink_file = (gatewayControl, satellite, majorTom) => command => {
const state = 'downlinking_from_system';
const progress_1_label = 'File chunks downlinked';
const tempFileLocation = path.join(__dirname, 'downlinked_files', filename);
const tempFileDir = path.dirname(tempFileLocation);
let progress_1_current = 0;
let progress_1_max = 0;

if (!fs.existsSync(tempFileDir)) {
fs.mkdirSync(tempFileDir, { recursive: true });
}

const tempFileStream = fs.createWriteStream(tempFileLocation);

const tempUpdateListener = ({ type, downlink_id, chunk }) => {
Expand Down

0 comments on commit 2d223af

Please sign in to comment.