[Mono-bugs] [Bug 458916] New: Implemetation errors on Copy.cs

bugzilla_noreply at novell.com bugzilla_noreply at novell.com
Sat Dec 13 06:49:49 EST 2008


           Summary: Implemetation errors on Copy.cs
           Product: Mono: Class Libraries
           Version: unspecified
          Platform: i686
        OS/Version: Windows Server 2008
            Status: NEW
          Severity: Normal
          Priority: P5 - None
         Component: Ms.Build
        AssignedTo: marek.sieradzki at gmail.com
        ReportedBy: themann at indyfantasysports.net
         QAContact: mono-bugs at lists.ximian.com
          Found By: ---

Created an attachment (id=259919)
 --> (https://bugzilla.novell.com/attachment.cgi?id=259919)
a patch that addresses the bugs/enhancements I've mentioned

I needed to use Mono's Copy.cs to get around an issue I'm having with
Microsoft's Copy task, in which I've noticed a few issues.  I have provided a
patch file which addresses most of these issues. I created the patch from
inside the mcs directory, as I had only checked out that directory.

First is a critical issue.  The implmentation had checked if the sourceFiles
lenght was equal to the destinationFiles length, before it deturmined whether
it was using DestinationFiles or DestinationFolder. Result is that it fails
with an exception if DestinationFolder is used.  I simply moved the code that
checks this to a more appropriate location (at a point where it's deturmined
that DestinationFiles is being used).

Another critical issue, if using DestinationFiles, the implementation does not
check first if the directory for the destinationFile exists, thus causing an
exception when attempting to copy the file to a nonexistant directory. To fix
this issue, I refactored the code in the DestinationFolder section so that the
directory creation code could be used by both.  As well, I check to ensure the
directory path contains a path before attempting to create the directory.

Another major issue is that the SourceFiles were being added to CopiedFiles. 
This is not the desired result, as CopiedFiles is expected to containt the
locations the files were copied to, not the location the files were copied
from.  I have modified this so that the destination location is added to the
CopiedFiles, as well as ensuring the original custom metadata of the
SourceFiles are copied over as well.

A couple of minor issues, I had replaced the double enumerator with an array
index lookup (the code is more apparent to it's intended goal this way), as
well I had replaced the single enumerator with a foreach.  I had also replaced
the well known metadata lookups with a lookup of the ItemSpec property.  That's
what the examples on MSDN used when obtaining a reference to a file/directory,
so I assume Microsoft's implementation probably uses it as well.  Since
ItemSpec is a relative path, I added a check to ensure the directory path isn't
empty before creating it.

A major minor issue, Microsoft's implementation only checks that the last
modification time on the files are equal; if the destination file was modified
more recently than the source file, Microsoft's implementation will still copy
the file if "SkipUnchangedFiles" is set to true. I thus have chaned the "Less
than or equal" to simply "equal."

As an enhancement, I've also added some logging to the task, so that files
being copied can be seen as they are copied.

Configure bugmail: https://bugzilla.novell.com/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the QA contact for the bug.

More information about the mono-bugs mailing list