Community
Vault Customization
Share your knowledge, ask questions, and explore popular Vault API, Data Standard, and VBA topics related to programming, creating add-ins, or working with the Vault API.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

FileManager AddFile timeout

0 REPLIES 0
Reply
Message 1 of 1
m.de.vriesTH5VM
265 Views, 0 Replies

FileManager AddFile timeout

I am using the following line of code to add a file to a Vault.

It is run in a loop as the tool handles potentially hundreds of thousands of files.

 

using (Stream sr = new FileStream(fpath, FileMode.Open, FileAccess.Read))
{
	fileIteration = Conn.FileManager.AddFile(fldr, Path.GetFileName(fpath), "Added by Vault Migration", DateTime.Now, assocs, null, FileClassification.None, false, sr);
}

Most of the time this works fine but every now and then the vault  or server is busy and this call throws an exception (which is caught and logged).

 

Is there a better way to retry the AddFile call than trying to do so in the catch clause?

I currently use

try

{

   AddFileToFolder(fpath, fldr);

}

catch(Exception ex)

{

   if (ExceptionAllowsRetry(ex))

   {

   try

   {

      AddFileToFolder(fpath, fldr);

   }

   catch (Exception ex2)

   {

      AddToLog($"File {fpath} could not be added to the Vault ({ex.Message} - {ex2.Message})")

   }

   }

}

 

This works some of the time, but not always, and it puts a heavy load on the vault server as files are added as quickly as possible. Not to mention the code looks clunky.

 

I wonder if there is a better way to wrap the AddFile() call in such a way that it does not put such a heavy load on the server, and can more gracefully deal with the inevitable conflicts that arise when adding terabytes of data to a vault.

 

 

 

0 REPLIES 0

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report