Skip to content

Commit

Permalink
Add more helpful error message when BBS download archive is not found (
Browse files Browse the repository at this point in the history
  • Loading branch information
ArinGhazarian authored Mar 24, 2023
1 parent be69010 commit 5ead78b
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 3 deletions.
3 changes: 2 additions & 1 deletion RELEASENOTES.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
- Improve error message when `migrate-repo` is used with a target personal access token (PAT) with insufficient permissions
- Ensure `--no-ssl-verify` flag is honored when downloading archives from GHES
- `--bbs-project` and `--bbs-repo` are now both required in `gh bbs2gh migrate-repo` command when `--bbs-server-url` is set
* Added `--keep-archive` flag to `gh gei migrate-repo` and `gh gei generate-script`. When migrating from GHES this will skip the step where we delete the archive from your machine, leaving it around as a local file.
- Added `--keep-archive` flag to `gh gei migrate-repo` and `gh gei generate-script`. When migrating from GHES this will skip the step where we delete the archive from your machine, leaving it around as a local file.
- Continue to next mannequin mapping in `gh gei reclaim-mannequin --csv` if a username doesn't exist
- Display more helpful message when the Bitbucket export archive is not found when using `gh bbs2gh migrate-repo`
9 changes: 8 additions & 1 deletion src/bbs2gh/Services/BbsSmbArchiveDownloader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,12 @@ private object CreateFileHandle(ISMBFileStore fileStore, string sharedFilePath)

return IsSuccessStatus(status)
? sharedFileHandle
: throw new OctoshiftCliException($"Couldn't create SMB file handle for \"{sharedFilePath}\" (Status Code: {status}).");
: throw new OctoshiftCliException(
$"Couldn't create SMB file handle for \"{sharedFilePath}\" (Status Code: {status})." +
(IsObjectPathNotFoundStatus(status) && BbsSharedHomeDirectory is BbsSettings.DEFAULT_BBS_SHARED_HOME_DIRECTORY_WINDOWS
? "This most likely means that your Bitbucket instance uses a non-default Bitbucket shared home directory, so we couldn't find your archive. " +
"You can point the CLI to a non-default shared directory by specifying the --bbs-shared-home option."
: ""));
}

private long? GetFileSize(ISMBFileStore fileStore, object sharedFileHandle)
Expand All @@ -218,4 +223,6 @@ private object CreateFileHandle(ISMBFileStore fileStore, string sharedFilePath)
private bool IsSuccessStatus(NTStatus status) => status is NTStatus.STATUS_SUCCESS;

private bool IsEndOfFileStatus(NTStatus status) => status is NTStatus.STATUS_END_OF_FILE;

private bool IsObjectPathNotFoundStatus(NTStatus status) => status is NTStatus.STATUS_OBJECT_PATH_NOT_FOUND;
}
7 changes: 6 additions & 1 deletion src/bbs2gh/Services/BbsSshArchiveDownloader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,12 @@ public async Task<string> Download(long exportJobId, string targetDirectory = IB

if (!_sftpClient.Exists(sourceExportArchiveFullPath))
{
throw new OctoshiftCliException($"Source export archive ({sourceExportArchiveFullPath}) does not exist.");
throw new OctoshiftCliException(
$"Source export archive ({sourceExportArchiveFullPath}) does not exist." +
(BbsSharedHomeDirectory is BbsSettings.DEFAULT_BBS_SHARED_HOME_DIRECTORY_LINUX
? "This most likely means that your Bitbucket instance uses a non-default Bitbucket shared home directory, so we couldn't find your archive. " +
"You can point the CLI to a non-default shared directory by specifying the --bbs-shared-home option."
: ""));
}

_fileSystemProvider.CreateDirectory(targetDirectory);
Expand Down

0 comments on commit 5ead78b

Please sign in to comment.