func fetchDirectoryDetails(ctx context.Context, ds internal.DataSource, dirPath string, mi *internal.ModuleInfo,
	licmetas []*licenses.Metadata, includeDirPath bool) (_ *Directory, err error) {
	defer derrors.Wrap(&err, "s.ds.fetchDirectoryDetails(%q, %q, %q, %v)", dirPath, mi.ModulePath, mi.Version, licmetas)

	if includeDirPath && dirPath != mi.ModulePath && dirPath != stdlib.ModulePath {
		return nil, fmt.Errorf("includeDirPath can only be set to true if dirPath = modulePath: %w", derrors.InvalidArgument)
	}

	if dirPath == stdlib.ModulePath {
		pkgs, err := ds.LegacyGetPackagesInModule(ctx, stdlib.ModulePath, mi.Version)
		if err != nil {
			return nil, err
		}
		return legacyCreateDirectory(&internal.LegacyDirectory{
			LegacyModuleInfo: internal.LegacyModuleInfo{ModuleInfo: *mi},
			Path:             dirPath,
			Packages:         pkgs,
		}, licmetas, includeDirPath)
	}

	dbDir, err := ds.LegacyGetDirectory(ctx, dirPath, mi.ModulePath, mi.Version, internal.AllFields)
	if errors.Is(err, derrors.NotFound) {
		return legacyCreateDirectory(&internal.LegacyDirectory{
			LegacyModuleInfo: internal.LegacyModuleInfo{ModuleInfo: *mi},
			Path:             dirPath,
			Packages:         nil,
		}, licmetas, includeDirPath)
	}
	if err != nil {
		return nil, err
	}
	return legacyCreateDirectory(dbDir, licmetas, includeDirPath)
}
// fetchDirectoryDetails fetches data for the directory specified by path and
// version from the database and returns a LegacyDirectory.
//
// includeDirPath indicates whether a package is included if its import path is
// the same as dirPath.
// This argument is needed because on the module "Packages" tab, we want to
// display all packages in the module, even if the import path is the same as
// the module path. However, on the package and directory view's
// "Subdirectories" tab, we do not want to include packages whose import paths
// are the same as the dirPath.
fetchDirectoryDetails fetches data for the directory specified by path and
version from the database and returns a LegacyDirectory.

includeDirPath indicates whether a package is included if its import path is
the same as dirPath.
This argument is needed because on the module "Packages" tab, we want to
display all packages in the module, even if the import path is the same as
the module path. However, on the package and directory view's
"Subdirectories" tab, we do not want to include packages whose import paths
are the same as the dirPath.
// fetchDirectoryDetails fetches data for the directory specified by path and // version from the database and returns a LegacyDirectory . // // includeDirPath indicates whether a package is included if its import path is // the same as dirPath . // This argument is needed because on the module " Packages " tab we want to // display all packages in the module even if the import path is the same as // the module path . However on the package and directory view ' s // " Subdirectories " tab we do not want to include packages whose import paths // are the same as the dirPath .
func fetchDirectoryDetails(ctx context.Context, ds internal.DataSource, dirPath string, mi *internal.ModuleInfo,
	licmetas []*licenses.Metadata, includeDirPath bool) (_ *Directory, err error) {
	defer derrors.Wrap(&err, "s.ds.fetchDirectoryDetails(%q, %q, %q, %v)", dirPath, mi.ModulePath, mi.Version, licmetas)
	if includeDirPath && dirPath != mi.ModulePath && dirPath != stdlib.ModulePath {
		return nil, fmt.Errorf("includeDirPath can only be set to true if dirPath = modulePath: %w", derrors.InvalidArgument)
	}
	if dirPath == stdlib.ModulePath {
		pkgs, err := ds.LegacyGetPackagesInModule(ctx, stdlib.ModulePath, mi.Version)
		if err != nil {
			return nil, err
		}
		return legacyCreateDirectory(&internal.LegacyDirectory{
			LegacyModuleInfo: internal.LegacyModuleInfo{ModuleInfo: *mi},
			Path:             dirPath,
			Packages:         pkgs,
		}, licmetas, includeDirPath)
	}
	dbDir, err := ds.LegacyGetDirectory(ctx, dirPath, mi.ModulePath, mi.Version, internal.AllFields)
	if errors.Is(err, derrors.NotFound) {
		return legacyCreateDirectory(&internal.LegacyDirectory{
			LegacyModuleInfo: internal.LegacyModuleInfo{ModuleInfo: *mi},
			Path:             dirPath,
			Packages:         nil,
		}, licmetas, includeDirPath)
	}
	if err != nil {
		return nil, err
	}
	return legacyCreateDirectory(dbDir, licmetas, includeDirPath)
}
func fetchDirectoryDetails ( ctx context . Context , ds internal . DataSource , dirPath string , mi * internal . ModuleInfo , licmetas [ ] * licenses . Metadata , includeDirPath bool ) ( _ * Directory , err error ) { defer derrors . Wrap ( & err , " " , dirPath , mi . ModulePath , mi . Version , licmetas ) if includeDirPath && dirPath != mi . ModulePath && dirPath != stdlib . ModulePath { return nil , fmt . Errorf ( " " , derrors . InvalidArgument ) } if dirPath == stdlib . ModulePath { pkgs , err := ds . LegacyGetPackagesInModule ( ctx , stdlib . ModulePath , mi . Version ) if err != nil { return nil , err } return legacyCreateDirectory ( & internal . LegacyDirectory { LegacyModuleInfo : internal . LegacyModuleInfo { ModuleInfo : * mi } , Path : dirPath , Packages : pkgs , } , licmetas , includeDirPath ) } dbDir , err := ds . LegacyGetDirectory ( ctx , dirPath , mi . ModulePath , mi . Version , internal . AllFields ) if errors . Is ( err , derrors . NotFound ) { return legacyCreateDirectory ( & internal . LegacyDirectory { LegacyModuleInfo : internal . LegacyModuleInfo { ModuleInfo : * mi } , Path : dirPath , Packages : nil , } , licmetas , includeDirPath ) } if err != nil { return nil , err } return legacyCreateDirectory ( dbDir , licmetas , includeDirPath ) }
fetchDirectoryDetails fetches data for the directory specified by path and
version from the database and returns a LegacyDirectory.
fetchDirectoryDetails fetches data for the directory specified by path and version from the database and returns a LegacyDirectory .