Skip to content

Commit

Permalink
Merge pull request #845 from veliovgroup/dev
Browse files Browse the repository at this point in the history
πŸ“¦ v2.2.1

-  πŸ‘¨β€πŸ’» Fix #842, a newly detected bug by @chrschae; Fixing case when `namingFunction` returns new nested path cause exception in `.write()` and `.load()` methods
  • Loading branch information
dr-dimitru authored Jun 29, 2022
2 parents f5a335e + 96d969d commit 313e842
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 10 deletions.
4 changes: 2 additions & 2 deletions .versions
2 changes: 1 addition & 1 deletion package.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package.describe({
name: 'ostrio:files',
version: '2.2.0',
version: '2.2.1',
summary: 'Upload files to a server or 3rd party storage: AWS:S3, GridFS, DropBox, and other',
git: 'https://github.com/veliovgroup/Meteor-Files',
documentation: 'README.md'
Expand Down
20 changes: 13 additions & 7 deletions server.js
Original file line number Diff line number Diff line change
Expand Up @@ -1254,9 +1254,12 @@ class FilesCollection extends FilesCollectionCore {

result._id = fileId;

fs.stat(opts.path, (statErr, stats) => {
fs.stat(opts.path, (statError, stats) => {
bound(() => {
if (statErr || !stats.isFile()) {
if (statError || !stats.isFile()) {
const paths = opts.path.split('/');
paths.pop();
fs.mkdirSync(paths.join('/'), { recursive: true });
fs.writeFileSync(opts.path, '');
}

Expand Down Expand Up @@ -1364,9 +1367,12 @@ class FilesCollection extends FilesCollectionCore {
});
};

fs.stat(opts.path, (statErr, stats) => {
fs.stat(opts.path, (statError, stats) => {
bound(() => {
if (statErr || !stats.isFile()) {
if (statError || !stats.isFile()) {
const paths = opts.path.split('/');
paths.pop();
fs.mkdirSync(paths.join('/'), { recursive: true });
fs.writeFileSync(opts.path, '');
}

Expand Down Expand Up @@ -1394,10 +1400,10 @@ class FilesCollection extends FilesCollectionCore {
});

if (!result.size) {
fs.stat(opts.path, (statError, newStats) => {
fs.stat(opts.path, (statErrorOnEnd, newStats) => {
bound(() => {
if (statError) {
callback && callback(statError);
if (statErrorOnEnd) {
callback && callback(statErrorOnEnd);
} else {
result.versions.original.size = (result.size = newStats.size);
storeResult(result, callback);
Expand Down
1 change: 1 addition & 0 deletions write-stream.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ export default class WriteStream {
fs.mkdirSync(paths.join('/'), { recursive: true });
fs.writeFileSync(this.path, '');
}

fs.open(this.path, 'r+', this.permissions, (oError, fd) => {
bound(() => {
if (oError) {
Expand Down

0 comments on commit 313e842

Please sign in to comment.