Access is denied: [The target file is a directory, not a file:

Hi,
Our deployments are intermittent failing with “Access is denied: [The target file is a directory, not a file:”. Previously it failed pointed issue with .resx file - and this time it fails and point to .png files. The deployment works to non-Production and only fails in Production deployments. I checked logs and both match on Calamari version etc.

Octopus Server version: 3.14.15926+Branch.master.Sha.xxxxxxxx
04:51:03 Verbose | Environment Information:
| OperatingSystem: Microsoft Windows NT 6.2.9200.0
| OsBitVersion: x64
| Is64BitProcess: True
| CurrentUser: NT AUTHORITY\SYSTEM
| MachineName: xxxxxxxxx
| ProcessorCount: 2
| CurrentDirectory: C:\Windows\system32
| TempDirectory: C:\Windows\TEMP
| HostProcessName: Octopus.Server
04:51:03 Info | Deploying package ‘C:\Octopus\Files\MMS_RDP_PA_Files.1.0.1342.zip-392ee27a-4949-4558-b445-7281cbc5cf29’ to machine ‘https://xxxxxxxx:10933/
04:51:04 Verbose | Octopus Deploy: Calamari version 3.7.83
04:51:04 Verbose | Environment Information:
04:51:04 Verbose | OperatingSystem: Microsoft Windows NT 6.1.7601 Service Pack 1
04:51:04 Verbose | OsBitVersion: x64
04:51:04 Verbose | Is64BitProcess: True
04:51:04 Verbose | CurrentUser: NT AUTHORITY\SYSTEM
04:51:04 Verbose | MachineName: xxxxxxxxxx
04:51:04 Verbose | ProcessorCount: 8
04:51:04 Verbose | CurrentDirectory: C:\Octopus\Work\20190320115104-92057-335
04:51:04 Verbose | TempDirectory: C:\Windows\TEMP
04:51:04 Verbose | HostProcessName: Calamari
04:51:04 Info | Deploying package: C:\Octopus\Files\MMS_RDP_PA_Files.1.0.1342.zip-392ee27a-4949-4558-b445-7281cbc5cf29
04:51:05 Verbose | Extracting package to: C:\Octopus\Applications\PRD\MMS_RDP_PA_Files\1.0.1342_1
04:51:05 Verbose | Extracted 8 files

Extracted 8 files
03:45:37 Info | Copying package contents to ‘E:\MMS\WebApps\xxxxxxxxxxxxx\Site’
03:45:37 Verbose | Retry #1 on copy ‘E:\MMS\WebApps\xxxxxxxxxxxxx\header.jpg’. Exception: (5) Access is denied: [The target file is a directory, not a file: [\?\E:\MMS\WebApps\xxxxxxxxxxxxx\header.jpg]]
03:45:38 Verbose | Retry #2 on copy ‘E:\MMS\WebApps\xxxxxxxxxxxxx\header.jpg’. Exception: (5) Access is denied: [The target file is a directory, not a file: [\?\E:\MMS\WebApps\xxxxxxxxxxxxx\header.jpg]]
03:45:38 Verbose | Retry #3 on copy ‘E:\MMS\WebApps\xxxxxxxxxxxxx\header.jpg’. Exception: (5) Access is denied: [The target file is a directory, not a file: [\?\E:\MMS\WebApps\xxxxxxxxxxxxx\header.jpg]]
03:45:38 Verbose | Retry #4 on copy ‘E:\MMS\WebApps\xxxxxxxxxxxxx\header.jpg’. Exception: (5) Access is denied: [The target file is a directory, not a file: [\?\E:\MMS\WebApps\xxxxxxxxxxxxx\header.jpg]]
03:45:48 Verbose | Retry #54 on copy ‘E:\MMS\WebApps\xxxxxxxxxxxxx\header.jpg’. Exception: (5) Access is denied: [The target file is a directory, not a file: [\?\E:\MMS\WebApps\xxxxxxxxxxxxx\header.jpg]]
03:45:59 Verbose | Retry #104 on copy ‘E:\MMS\WebApps\xxxxxxxxxxxxx\header.jpg’. Exception: (5) Access is denied: [The target file is a directory, not a file: [\?\E:\MMS\WebApps\xxxxxxxxxxxxx\header.jpg]]
03:46:13 Verbose | Retry #154 on copy ‘E:\MMS\WebApps\xxxxxxxxxxxxx\header.jpg’. Exception: (5) Access is denied: [The target file is a directory, not a file: [\?\E:\MMS\WebApps\xxxxxxxxxxxxx\header.jpg]]
03:46:23 Verbose | Retry #204 on copy ‘E:\MMS\WebApps\xxxxxxxxxxxxx\header.jpg’. Exception: (5) Access is denied: [The target file is a directory, not a file: [\?\E:\MMS\WebApps\xxxxxxxxxxxxx\header.jpg]]
03:46:33 Verbose | Retry #254 on copy ‘E:\MMS\WebApps\xxxxxxxxxxxxx\header.jpg’. Exception: (5) Access is denied: [The target file is a directory, not a file: [\?\E:\MMS\WebApps\xxxxxxxxxxxxx\header.jpg]]
03:46:39 Error | System.UnauthorizedAccessException: (5) Access is denied: [The target file is a directory, not a file: [\?\E:\MMS\WebApps\xxxxxxxxxxxxx\header.jpg]]
03:46:39 Error | at Alphaleonis.Win32.NativeError.ThrowException(UInt32 errorCode, String readPath, String writePath)
03:46:39 Error | at Alphaleonis.Win32.Filesystem.File.CopyMoveCore(Boolean isFolder, KernelTransaction transaction, String sourceFileName, String destinationFileName, Boolean preserveDates, Nullable1 copyOptions, Nullable1 moveOptions, CopyMoveProgressRoutine progressHandler, Object userProgressData, CopyMoveResult copyMoveResult, PathFormat pathFormat)
03:46:39 Error | at Alphaleonis.Win32.Filesystem.File.Copy(String sourceFileName, String destinationFileName, Boolean overwrite)
03:46:39 Error | at Calamari.Integration.FileSystem.CalamariPhysicalFileSystem.RetryTrackerFileAction(Action fileAction, String target, String action)
03:46:39 Error | at Calamari.Integration.FileSystem.CalamariPhysicalFileSystem.CopyDirectory(String sourceDirectory, String targetDirectory, CancellationToken cancel)
03:46:39 Error | at Calamari.Integration.FileSystem.CalamariPhysicalFileSystem.CopyDirectory(String sourceDirectory, String targetDirectory, CancellationToken cancel)
03:46:39 Error | at Calamari.Integration.FileSystem.CalamariPhysicalFileSystem.CopyDirectory(String sourceDirectory, String targetDirectory, CancellationToken cancel)
03:46:39 Error | at Calamari.Integration.FileSystem.CalamariPhysicalFileSystem.CopyDirectory(String sourceDirectory, String targetDirectory, CancellationToken cancel)
03:46:39 Error | at Calamari.Integration.FileSystem.CalamariPhysicalFileSystem.CopyDirectory(String sourceDirectory, String targetDirectory, CancellationToken cancel)
03:46:39 Error | at Calamari.Integration.FileSystem.CalamariPhysicalFileSystem.CopyDirectory(String sourceDirectory, String targetDirectory)
03:46:39 Error | at Calamari.Deployment.Conventions.CopyPackageToCustomInstallationDirectoryConvention.Install(RunningDeployment deployment)
03:46:39 Error | at Calamari.Deployment.ConventionProcessor.RunInstallConventions()
03:46:39 Error | at Calamari.Deployment.ConventionProcessor.RunConventions()

Hi Brian,

Thanks for reaching out!

The fact that it fails intermittently makes me believe that whatever service is consuming those files, is still running at the moment of the deploy.

By looking at your log I couldn’t figure out if you are deploying an IIS Site, a windows Service or any other type of service, but my recommendation is that you add a step to stop that service before the “deploy” step. You might also want to consider adding a wait for a couple of seconds before starting the “deploy” step, just to make sure the files aren’t locked (i.e. using start-sleep in powershell).

Let me know if that helps.

Regards,
Dalmiro

Thanks.

The issue was due to file on disk in ReadOnly mode. Removing the file from ReadOnly resolved the issue

Thanks & Regards
Shams

Hi Shams,

Glad to hear you were able to get to the bottom of this :slight_smile:

Cheers

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.