Categories > OpenTBS with DOCX >

I cant delete the template after the new file is saved.

The forum is closed. Please use Stack Overflow for submitting new questions. Use tags: tinybutstrong , opentbs
By: Ricardo
Date: 2015-10-21
Time: 11:44

I cant delete the template after the new file is saved.

Good morning,
I have a problem regarding TBS, this is what my script does:

- Load a template
- replace an image inside the template.
- Because i cant save the changes in the template, I save the modified file on the server with a new name.
- after the file is created and saved i verify if the new file exists, and if the new file exists i delete the template.

Here is the problem, when i try to delete the template I cant because its still in use...
Is there a way to unload the template, end TBS or other action that frees the template so i can delete it?

*the delete script works because if i try to delete other file in the same folder it works.

Thank you in advance.

Regards
By: Ricardo
Date: 2015-10-21
Time: 14:49

Re: I cant delete the template after the new file is saved.

I fixed this issue adding the following to tbs_plugin_opentbs.php:

@$this->Close($File);

I added it right after line 206:

} elseif(($Render & OPENTBS_FILE)==OPENTBS_FILE) { 
            // to file
            $this->Flush(TBSZIP_FILE, $File);

so it ended like this:

} elseif(($Render & OPENTBS_FILE)==OPENTBS_FILE) {
            // to file
            $this->Flush(TBSZIP_FILE, $File);
            @$this->Close($File);

I dont know if is the best way but it works, if anybody have a better solution, please let me know.

regards
By: Skrol29
Date: 2015-10-28
Time: 11:37

Re: I cant delete the template after the new file is saved.

Tanks, I will have a look at this point for the next OpenTBS version (probably soon)

There is a workaround for closing the template without pathching OpenTBS :

- unset the TBS variable
or :
- $TBS->TbsZip->Close();
By: Ricardo
Date: 2015-10-29
Time: 19:13

Re: I cant delete the template after the new file is saved.

Thank you, I wil try it.