job000481

norman_morse (Norman Morse)
Norman Morse created this job , modified by Perforce maintenance
Open
Can't get metadata for newly added files

From internal case 00228248

1. Add a file to a depot (e.g. p4.exe add //depot/file.txt)

2. Get a list of opened files (IList<p4.File> p4Files = this.p4Repo.GetOpenedFiles(null, null);)

3. Get metadata for the newly opened file (foreach (p4.File p4File in p4Files) { IList<p4.FileMetaData> metaList = this.p4Repo.GetFileMetaData(null, p4File); }

Result:

The metadata for that file will be null

This is caused by two things:

1. The FileSpec object that is returned by GetOpenedFiles has a revision number of 1 (see below.) Since this is a newly added file it doesn't actually have a revision number yet.

- p4File {//depot/FMThresholdP4/external/SCAPI/Binaries/Microsoft.Scapi.Test.dll.config#1} Perforce.P4.File
- base {//depot/FMThresholdP4/external/SCAPI/Binaries/Microsoft.Scapi.Test.dll.config#1} Perforce.P4.FileSpec {Perforce.P4.File}
+ ClientPath {//dtunnell_T10-A8-DTUNNELL_FMThresholdP4/external/SCAPI/Binaries/Microsoft.Scapi.Test.dll.config} Perforce.P4.ClientPath
+ DepotPath {//depot/FMThresholdP4/external/SCAPI/Binaries/Microsoft.Scapi.Test.dll.config} Perforce.P4.DepotPath
LocalPath null Perforce.P4.LocalPath
+ Version {#1} Perforce.P4.VersionSpec {Perforce.P4.Revision}

2. Internal to GetFileMetaData in Repository.cs the revision number is added to the file. So in the example above it would run fstat on //depot/file.txt#1. That returns "no such files"

As a workaround I'm setting the revision number to null for anything that is an add. By doing that it will successfully run p4 fstat and return the proper metadata. You can reproduce this behavior on the command line:

p4 fstat //depot/FMThresholdP4/external/SCAPI/Binaries/Microsoft.Scapi.Test.dll.config

... depotFile //depot/FMThresholdP4/external/SCAPI/Binaries/Microsoft.Scapi.Test.dll.config
... clientFile F:\Perforce\All\FMThresholdP4\external\SCAPI\Binaries\Microsoft.Scapi.Test.dll.config
... isMapped
... action add
... change 486786
... type utf8
... actionOwner REDMOND\dtunnell

p4 fstat //depot/FMThresholdP4/external/SCAPI/Binaries/Microsoft.Scapi.Test.dll.config#1

//depot/FMThresholdP4/external/SCAPI/Binaries/Microsoft.Scapi.Test.dll.config#1 - no such file(s).

Note that setting the revision to zero will not work:

p4 fstat //depot/FMThresholdP4/external/SCAPI/Binaries/Microsoft.Scapi.Test.dll.config#0

//depot/FMThresholdP4/external/SCAPI/Binaries/Microsoft.Scapi.Test.dll.config#0 - no such file(s).
  • Details
  • Comments -
Status
Open
Project
perforce-software-p4api-net
Severity
A
Reported By
Norman Morse
Reported Date
Modified By
Perforce maintenance
Modified Date
Owned By
norman_morse
Type
Bug