SiavashBamshadnia / Laravel-Source-Encrypter

Laravel and Lumen Source Code Encrypter
MIT License
548 stars 126 forks source link

error when copy skipped file #30

Closed jamesRUS52 closed 1 year ago

jamesRUS52 commented 1 year ago

when first file in directory not a .php you skip encode it and just copy, but copy cannot be successfully completed because target directory not createad yet. It create only after first php file will be processed

{code} root@8a2df20797da:/iims# php artisan encrypt-source --force Encryption of gitignore files is not currently supported. These files will be copied without change.

ErrorException

copy(/iims/encrypted//database/.gitignore): Failed to open stream: No such file or directory

at vendor/laravel/framework/src/Illuminate/Filesystem/Filesystem.php:322 318▕ @return bool 319▕ / 320▕ public function copy($path, $target) 321▕ { ➜ 322▕ return copy($path, $target); 323▕ } 324▕ 325▕ /* 326▕ Create a symlink to the target file or directory. On Windows, a hard link is created if the target is a file.

  +17 vendor frames 

18 artisan:37

{code}

I think you should check if target directory exists before copy skipping files.

SiavashBamshadnia commented 1 year ago

Hi. Actually I do create directories on https://github.com/SiavashBamshadnia/Laravel-Source-Encrypter/blob/master/src/SourceEncryptCommand.php#L90 If you are using Linux, please check the ownership of your project directory. Is it same as your current user?

jamesRUS52 commented 1 year ago

It's not problem with user. It's problem with copy original (not encoded) file to target directory which not created yet, because this is a first file from this directory, but target directory created only when first encoded file will be transfered to it.

try your code with directory that contains for example .gitignore file e.g. database directory from fresh laravel instalation that contain .gitignore

SiavashBamshadnia commented 1 year ago

Actually I don't have any Linux-based system and for now, I can't install one on VM. Could you please replace the file vendor/sbamtr/laravel-source-encrypter/src/SourceEncryptCommand.php with the attached file and tell me if it works? (I compressed it.) Thanks.

SourceEncryptCommand.zip

jamesRUS52 commented 1 year ago

yep, it's work now