Jump to content


Multiple issues with P4API.NET

P4API.NET

  • Please log in to reply
5 replies to this topic

#1 Androvald

Androvald

    Newbie

  • Members
  • Pip
  • 3 posts

Posted 20 April 2018 - 01:03 AM

I'm having multiple issues with the latest version of P4API.NET:

1. Cannot cancel long commands
In the latest version of P4API.NET the KeepAlive functionality has been ripped out, and there's no longer any way to neatly cancel long running commands on user interaction. The only way to do so appears to just kill the perforce connection, killing all active commands rather than just the one that you want to cancel. Due to the way the system works, you cannot get a P4Server for a different thread, and getting a command id for the Client / Repository functions is mostly just guess work.

I guess if you are refactoring it, having it work with CancellationTokens and return async tasks would be nice, but I can understand that being a lot of work.

2. GetFileContents / GetFileContentsEx do not properly get Unicode file contents
When getting file data with these commands the text output gets corrupted file contents for higher number unicode text. In this case I'm reading mixed English / Russian UTF-16 content and I'm just getting nonsense for the higher Russian characters, but the English is fine:

Expected:
ПОМОЩЬ
Actual:
ПОМОЩЬ

When I make it write to a file on disk I can read the file correctly, however:

3. GetFileContents / GetFileContentsEx with a file output argument locks the file so it cannot be deleted later

Writing code like:
var tmpFile = Path.GetTempFileName();
var fileContents = Repository.GetFileContents(new GetFileContentsCmdOptions(GetFileContentsCmdFlags.None, tmpFile), fileSpec);
using (var stream = File.OpenRead(tmpFile))
{
  //.. read file
}
System.IO.File.Delete(tmpFile);
Causes an UnauthorizedAccessException on the delete. I've tried putting it into a loop until the file deletes, with a Thread.Sleep, however the file never gets released.

#2 p4bill

p4bill

    Advanced Member

  • Members
  • PipPipPip
  • 202 posts

Posted 20 April 2018 - 04:47 PM

Could you please confirm the latest version that you are using is 2018.1.163.6632 ?

#3 Androvald

Androvald

    Newbie

  • Members
  • Pip
  • 3 posts

Posted 20 April 2018 - 06:10 PM

Yes, the 64-bit version of that. We have mainly switched back to an older version (2015.1.103.4687) that still has the IKeepAlive working for cancellation, but I downloaded the latest version and checked that these issues do indeed still exist in the latest version. We are still running an older version of the server (P4D/LINUX26X86_64/2013.3/945880 (2014/10/07)) however.

#4 p4bill

p4bill

    Advanced Member

  • Members
  • PipPipPip
  • 202 posts

Posted 20 April 2018 - 08:04 PM

I am able to repro the Unicode contents issue. Are all 3 issues resolved with your rollback to 2015.1?

#5 Androvald

Androvald

    Newbie

  • Members
  • Pip
  • 3 posts

Posted 21 April 2018 - 12:12 AM

No, only the cancellation issue. Turns out I might not be able to use the older version, as it crashes when sending requests on multiple threads.

I've attached a test project I've used to replicate this issue. Just drop in P4API.NET64 2018.1, switch the path in GetFileContentsFail.cs and depending on what you're testing against, the code in KeepAliveTest.cs (I'm not sure if your //depot/... changelist query takes over 30 seconds normally).

Attached Files



#6 p4bill

p4bill

    Advanced Member

  • Members
  • PipPipPip
  • 202 posts

Posted 24 April 2018 - 03:57 PM

Thank you for the test project. We'll continue to investigate here, but it would be good if you could contact support@perforce.com to open a case to track these issues.





Also tagged with one or more of these keywords: P4API.NET

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users