Saturday 11 August 2012

"\" and "\\" character issues

Now we are ready to look at the "/" and "\\" character issues. As we know, the path separator in Linux is "/", while in windows it is "\\".

Mono has two built-in mechanisms for dealing with these differences:

(1) When mono is compiled with IS_PORTABILITY_SET, then in the mono CLR, for a unix system, AltDirectorySeparatorChar is defined as "\\". (Otherwise AltDirectorySeparatorChar is defined as "/")

(2) Running the mono app with the MONO_IOMAP=all environment variable set also sets the AltDirectorySeparatorChar to "\\" on Unix systems. However, running Umbraco with this environment variable set is slow and prone to crashes.

I am going to go for a third option, where I make the path character issues explicit in code (with help from the MultiPlatformHelper class):

(3) Resolving path separator character issues in the Umbraco code itself.

The changes so far impact the downloading and installation of packages.


Developer > Packages
Could not find a part of the path ".../umbraco/presentation/App_Data/packages/created/createdPackages.config".
If this directory / file is missing get it from a working install

Developer > Packages
You get this error after clicking "OK" to install a package
The resource cannot be found.
Details: Requested URL: /umbraco/developer/packages/proxy.htm
Why? Umbraco referrer url is:
Notice the casing.
Solutions: rename local Packages folder to packages, or set a symbolic link.
We ll do the symbolic link for now:
cd umbraco/presentation/umbraco/developer
ln -s Packages packages

Developer > Packages
Error - file not found. Could not find file named '.../umbraco/presentation/App_Data/packages\...
In .../umbraco/cms/businesslogic/Packager/Repositories/Repository.cs line 209,
"packages\\" + packageGuid + ".umb"

return String.Format ("packages{0}{0}{1}.umb", Path.DirectorySeparatorChar, packageGuid);

Now we are ready to proceed with the alterations:

Developer > Packages
Could not find file ".../umbraco/presentation/App_Data/fc9f3959-3764-4678-a14e-139974cbfe30/package.xml
Decompressed File names look like: 09b6762e-67b1-4cba-b0d9-14652ddcbb30\package

Replace .../umbraco/cms/businesslogic/Packager/Installer.cs line 963:964 with:
      string entryName = theEntry.Name;

      if (Path.DirectorySeparatorChar.ToString() == MultiPlatformHelper.UNIX_DIRSEP)
entryName = entryName.Replace(MultiPlatformHelper.WIN_DIRSEP, Path.DirectorySeparatorChar.ToString());

      string directoryName = Path.GetDirectoryName(entryName);
      string fileName = Path.GetFileName(entryName);

Developer > Packages
After installation we find under .../umbraco/presentation, a directory called:
...\umbraco\presentation\, which contains the package files.

In .../umbraco/cms/businesslogic/Packager/Installer.cs
Alter lines 814:815 to
if (Path.DirectorySeparatorChar.ToString() == MultiPlatformHelper.WIN_DIRSEP)
path = MultiPlatformHelper.ConvertPathFromUnixToWin(path);
fileName = MultiPlatformHelper.ConvertPathFromUnixToWin(fileName);

No comments:

Post a Comment

Note: only a member of this blog may post a comment.