JDownloader Community - Appwork GmbH
 

Notices

Reply
 
Thread Tools Display Modes
  #1  
Old 24.10.2017, 00:05
fred_gaou's Avatar
fred_gaou fred_gaou is offline
DSL User
 
Join Date: Mar 2016
Location: France
Posts: 39
Lightbulb [EventScripter] writeFile() method improvements

Hi,

If "append" is false and file already exists, then writeFile does nothing and leave the file as it is. I understand it is by design but could we add a parameter to force overwriting existing file in this case?
Reply With Quote
  #2  
Old 24.10.2017, 11:24
Jiaz's Avatar
Jiaz Jiaz is offline
JD Manager
 
Join Date: Mar 2009
Location: Germany
Posts: 79,290
Default

Why not just use the 'deleteFile(Path,recursive)' method to delete the file first?

I don't think that a new method is required if you can achieve the same with existing 'deleteFile' method.

I also have doubts about the syntax. New method to force overwrite. Does it have more priority than append? what if user calls append and overwrite, should it append or overwrite?
__________________
JD-Dev & Server-Admin
Reply With Quote
  #3  
Old 24.10.2017, 17:49
fred_gaou's Avatar
fred_gaou fred_gaou is offline
DSL User
 
Join Date: Mar 2016
Location: France
Posts: 39
Default

May an overwrite(path) method that create or overwrite if file exists?

Yes, one can still use delete() method. In fact, I expected that append=false overwrite existing file so I just need to control, dynamically change that variable when needed.
Reply With Quote
  #4  
Old 24.10.2017, 18:50
Jiaz's Avatar
Jiaz Jiaz is offline
JD Manager
 
Join Date: Mar 2009
Location: Germany
Posts: 79,290
Default

Why not simply check for file existance and then delete if required or use append=true?
__________________
JD-Dev & Server-Admin
Reply With Quote
  #5  
Old 24.10.2017, 18:55
fred_gaou's Avatar
fred_gaou fred_gaou is offline
DSL User
 
Join Date: Mar 2016
Location: France
Posts: 39
Default

Quote:
Originally Posted by Jiaz View Post
Why not simply check for file existance and then delete if required or use append=true?
Yes, we can do that. It just add more check than simply use append to actually append or overwrite.
Reply With Quote
  #6  
Old 24.10.2017, 19:59
Jiaz's Avatar
Jiaz Jiaz is offline
JD Manager
 
Join Date: Mar 2009
Location: Germany
Posts: 79,290
Default

Code:
if (append){
write(append)
}else{
delete(..)
write()
}
no additional check required. Just one more if statement
__________________
JD-Dev & Server-Admin
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

All times are GMT +2. The time now is 09:01.
Provided By AppWork GmbH | Privacy | Imprint
Parts of the Design are used from Kirsch designed by Andrew & Austin
Powered by vBulletin® Version 3.8.10 Beta 1
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.