package hh.dejsem.net;

import hh.dejsem.K;
import hh.dejsem.fm.NetTaskRef;
import hh.lib.D;

/**
 * copy from server asynchronously
 */
public class PullFromServer extends ServerCopy {

	public PullFromServer(D d, NetTaskRef netTaskRef) throws Exception  { super(d, netTaskRef); }

	@Override
	protected Void doInBackground(Void... params) {
		super.doInBackground();
		try { if(netTaskRef.go) netConn.pullSrv(); }
		catch(Exception e) { if(!(K.EntryNotFound.class.isInstance(e) || K.End.class.isInstance(e))) abend(null, e); }
		finally { try { netConn.connClose(); } catch(Exception e) {} }
		return null;
	}

	@Override
	void completePostExecute() { notifyRefresh(); }
}
