Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Bug in copy.lua, mkdir.lua and rename.lua (updated) #411

Merged
merged 3 commits into from
Jan 13, 2018
Merged

Fix Bug in copy.lua, mkdir.lua and rename.lua (updated) #411

merged 3 commits into from
Jan 13, 2018

Conversation

JakobDev
Copy link
Contributor

@JakobDev JakobDev commented Aug 9, 2017

This is a Updated Version of #404

The Reason for the Update is, that a Commit is not bound to my Account and maybe this will make Problems with Credits Generation.

Copy link
Contributor

@SquidDev SquidDev left a comment

Choose a reason for hiding this comment

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

If only for consistency with the rest of the codebase, please don't use == true.

@redfast00
Copy link

Are you using Codecuriosity?

@Lignum
Copy link
Contributor

Lignum commented Aug 9, 2017

The Reason for the Update is, that a Commit is not bound to my Account and maybe this will make Problems with Credits Generation.

No, it wouldn't. If you appear on this page at all, you will appear in the credits. Either way, next time you could do a rebase to fix the faulty commits.

@@ -10,7 +10,9 @@ local sDest = shell.resolve( tArgs[2] )
local tFiles = fs.find( sSource )
if #tFiles > 0 then
for n,sFile in ipairs( tFiles ) do
if fs.isDir( sDest ) then
if fs.exists( sDest ) == true then
Copy link
Owner

Choose a reason for hiding this comment

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

This check is incorrect. "copy existingfile existingdir" is perfectly valid, hence the isDir() check on the very next line, please move it inside the "#tFiles == 1" branch and remove the "== true"

@@ -5,5 +5,11 @@ if #tArgs < 1 then
end

local sNewDir = shell.resolve( tArgs[1] )

if fs.exists( sNewDir ) == true then
Copy link
Owner

Choose a reason for hiding this comment

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

This check is unnecessary. Making a dir that already exists should just silently suceed.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, when it is a Directory. But if it is a normal file, it will give a lua error.

@@ -6,4 +6,9 @@ end

local sSource = shell.resolve( tArgs[1] )
local sDest = shell.resolve( tArgs[2] )

if fs.exists( sDest ) == true then
Copy link
Owner

Choose a reason for hiding this comment

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

This is the only check in this PR that's actually meaningful...
Please remove the "== true" though.

@JakobDev
Copy link
Contributor Author

@dan200 Changes are now done.

btw: Here's a screen, that shows, that mkdir will crash, if the file exists.
2017-09-12_18 16 12

@@ -5,5 +5,11 @@ if #tArgs < 1 then
end

local sNewDir = shell.resolve( tArgs[1] )

if fs.exists( sNewDir ) then
Copy link
Owner

Choose a reason for hiding this comment

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

Change to "fs.exists(sNewDir) and not fs.isDir(sNewDir)"
It's perfectly okay to "make" a directory that already exists (it should silently succeed

@JakobDev
Copy link
Contributor Author

@dan200 The Check is now added

@dan200 dan200 merged commit f30c4f1 into dan200:master Jan 13, 2018
@@ -13,7 +13,11 @@ if #tFiles > 0 then
if fs.isDir( sDest ) then
fs.copy( sFile, fs.combine( sDest, fs.getName(sFile) ) )
elseif #tFiles == 1 then
fs.copy( sFile, sDest )
if fs.exists( sDest ) then
printError( "Destination exists" )

Choose a reason for hiding this comment

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

SHOULD request of overwrite file instead of drop error and quit.
fs.copy(sFile, sDest) like use --force argument in POSIX/GNU cp.

@SquidDev
Copy link
Contributor

CraftOS has never aimed to be POSIX compliant, but I agree it'd be nice to have.

@JakobDev JakobDev deleted the copyfixup branch January 19, 2018 15:07
ccserver pushed a commit to ccserver/ComputerCraft that referenced this pull request Sep 16, 2019
Fix Bug in copy.lua, mkdir.lua and rename.lua (updated)
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.

6 participants