Skip to content

[9.x] Adds isEqual to compare file hashes in filesystem - #41586

Merged
taylorotwell merged 4 commits into
laravel:9.xfrom
DarkGhostHunter:feat/file_equal_to
Mar 21, 2022
Merged

[9.x] Adds isEqual to compare file hashes in filesystem#41586
taylorotwell merged 4 commits into
laravel:9.xfrom
DarkGhostHunter:feat/file_equal_to

Conversation

@DarkGhostHunter

Copy link
Copy Markdown
Contributor

What?

Allows to compare two files if these exists and their hashes are the same.

use Illuminate\Support\Facades\File;

if (File::isEqual('foo.txt', 'bar.txt')) {
   return 'Both files are equal.'
}

It will always return false if one of the compared files doesn't exist.

Why?

Useful to check if a file copied was later edited without using exists() and hash() damn every time.

BC?

Is not expected the developer to have a macro of the same name for different functionality.

@driesvints driesvints changed the title [9.x] Adds isEqual to compare file hashes in filesystem. [9.x] Adds isEqual to compare file hashes in filesystem Mar 21, 2022
@taylorotwell
taylorotwell merged commit 89e43ae into laravel:9.x Mar 21, 2022
@DarkGhostHunter
DarkGhostHunter deleted the feat/file_equal_to branch March 21, 2022 17:23
crynobone added a commit to crynobone/framework that referenced this pull request Mar 22, 2022
taylorotwell pushed a commit to illuminate/support that referenced this pull request Mar 22, 2022
@vlakoff

vlakoff commented Feb 19, 2025

Copy link
Copy Markdown
Contributor

Notes:

@vlakoff

vlakoff commented Feb 19, 2025

Copy link
Copy Markdown
Contributor

Now that we can replace MD5 with xxh128, I have submitted PR #54690.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants