Release 0.1

In this release, we were asked to analyze Filer, a web filesystem project based on node.js, and find a bug to fix or write a test for it.

Looking through the project and its tests, I thought it would interesting to include a test for fs.exists(). Basically, it checks if a given path exists in the file system.

I filed the issue #475 to include a test for the case when the path is a symbolic link and there is no resulting directory.

it('should follow symbolic links and return false if for the resulting path does not exist', function(done) {
    var fs = util.fs();

    fs.open('/myfile', 'w', function(error, fd) {
      if(error) throw error;

      fs.close(fd, function(error) {
        if(error) throw error;

        fs.symlink('/myfile', '/myfilelink', function(error) {
          if(error) throw error;
        
          fs.unlink('/myfile', function(err) {
            if(err) throw err;
          
            fs.exists('/myfilelink', function(result) {
              expect(result).to.be.false;
              done();
            });
          });
        });
      });
    });
  });

It simply creates a directory /myfile by using fs.open(), then creates a symbolic link to the newly created directory using fs.symlink(). Right after that, we delete the directory /myfile by using fs.unlink() and finally we check if /myfile exists using the function fs.exists() expecting false to be returned

After running the proper tests, I could confirm the my code works and doesn’t affect the Filer project. Upon this finding, I submitted a pull request under number #519.

I wanted to work on other issue, to create a test for fs.rmdir() to test when the path is a hard link. I encountered some problems with the code, so I sought help in the Slack group. Jeffrey Espiritu explained to me that hard link can’t be linked to a directory, but rather a file.

After that, I started looking into other people’s pull request and contribute to them. That’s when I stumbled upon the pull request #522, where our friend Peng-Qu was having a bit of difficulty getting it off the ground. There were minor issues with his code link forgetting to declare the var mode, and using the root directory as a parameter instead of a directory that doesn’t exist, so I gave him some suggestions on his code to get it running. At the time of writing, he hasn’t updated his pull request yet, but I would love to see his change, perhaps sometime totally different from my approach.

With this project, I have learnt the principles of open source, how to contribute to other projects and, most importantly, to think as “we” instead of “I”.

I still have some struggles with git and since it’s the first time I am working with it, I still haven’t gotten confident about it, but this first release is definitely a step forward. The biggest challenge for me is having my code viewed and reviewed by anyone right in the open, it’s definitely a new thing for me and something I am still working on.

I guess the biggest takeaway from this release is realizing how big projects are made of individuals like me, who work together to write a code that looks like it has been written by the same person. I am loving this sense of community!

Leave a Comment

(0 Comments)

Your email address will not be published. Required fields are marked *