Skip to content

Commit

Permalink
Dont use periods when generating a random name for the temporary dire…
Browse files Browse the repository at this point in the history
…ctory
  • Loading branch information
AlexVanderbist committed Feb 2, 2017
1 parent c2e479a commit 58e80a8
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

All notable changes to `temporary-directory` will be documented in this file

## 1.1.2 - 2017-02-02

- do not use periods when generating a name for the temporary directory

## 1.1.1 - 2017-02-02

- do not use spaces when generating a name for the temporary directory
Expand Down
2 changes: 1 addition & 1 deletion src/TemporaryDirectory.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public function create()
}

if (empty($this->name)) {
$this->name = str_replace(' ', '', microtime());
$this->name = str_replace([' ', '.'], '', microtime());
}

if ($this->forceCreate && file_exists($this->getFullPath())) {
Expand Down

3 comments on commit 58e80a8

@marcusmoore
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In my PR I wasn't sure about .'s being an issue and I ended up only removing spaces 😒

Just curious, was microtime() originally used instead of generating a random string (or similar mechanism) in order to connect the directory to a specific time? I've seen it used in this way before but I'm not sure if that's following a convention?

@AlexVanderbist
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@marcusmoore microtime() was indeed used as an alternative to generating a random string. This way the directories would be (sort of) time-stamped and there wouldn't be any chance of colliding directory names.

@marcusmoore
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@AlexVanderbist Thanks for the insight!

Please sign in to comment.